]> granicus.if.org Git - musl/commitdiff
remove everything related to forkall
authorRich Felker <dalias@aerifal.cx>
Wed, 23 May 2012 02:43:27 +0000 (22:43 -0400)
committerRich Felker <dalias@aerifal.cx>
Wed, 23 May 2012 02:43:27 +0000 (22:43 -0400)
i made a best attempt, but the intended semantics of this function are
fundamentally contradictory. there is no consistent way to handle
ownership of locks when forking a multi-threaded process. the code
could have worked by accident for programs that only used normal
mutexes and nothing else (since they don't actually store or care
about their owner), but that's about it. broken-by-design interfaces
that aren't even in glibc (only solaris) don't belong in musl.

include/unistd.h
src/internal/libc.h
src/thread/forkall.c [deleted file]
src/thread/synccall.c

index 693c54dc8ab5a3d2c1ab2c8cb613009778b2b39b..e4e3ac59e4f8d771ce279fc66964d004f2de7f05 100644 (file)
@@ -168,7 +168,6 @@ char *getusershell(void);
 #endif
 
 #ifdef _GNU_SOURCE
-pid_t forkall(void);
 int setresuid(uid_t, uid_t, uid_t);
 int setresgid(gid_t, gid_t, gid_t);
 int getresuid(uid_t *, uid_t *, uid_t *);
index 78fca47fccd53eb60eb4745442ba2608341e8e7b..0ec3691e4f512f2b21dda5f238c0584b559e7cc8 100644 (file)
@@ -52,7 +52,6 @@ void __unlockfile(FILE *);
 #define UNLOCK(x) (libc.threads_minus_1 ? (__unlock(x),1) : ((void)(x),1))
 
 void __synccall(void (*)(void *), void *);
-void __synccall_wait(void);
 int __setxid(int, int, int, int);
 
 extern char **__environ;
diff --git a/src/thread/forkall.c b/src/thread/forkall.c
deleted file mode 100644 (file)
index 6810ea5..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#if 0
-#include "pthread_impl.h"
-#include <setjmp.h>
-
-struct thread {
-       struct thread *next;
-       pthread_t td;
-       jmp_buf jb;
-       void *tmp, *stack;
-};
-
-struct ctx {
-       struct thread *list;
-       pthread_t caller;
-       pid_t pid;
-       size_t cnt;
-       pthread_barrier_t barrier;
-};
-
-static void restart_thread(pthread_t self)
-{
-       struct thread *t = self->start_arg;
-       self->start_arg = t->tmp;
-       self->pid = getpid();
-       longjmp(t->jb, 1);
-}
-
-static void do_forkall(void *p)
-{
-       struct ctx *c = p, *volatile cv = c;
-       char tmpstack[2048];
-       struct thread *tp, t = {
-               .td = __pthread_self(),
-               .next = c->list,
-               .stack = tmpstack+1024
-       };
-
-       if (t.td != c->caller) {
-               c->cnt++;
-               t.tmp = t.td->start_arg;
-               t.td->start_arg = &t;
-               if (setjmp(t.jb)) {
-                       c = cv;
-                       if (c->pid) return;
-                       pthread_barrier_wait(&c->barrier);
-                       return;
-               }
-               c->list = &t;
-               __synccall_wait();
-               return;
-       }
-       c->pid = syscall(SYS_fork);
-       if (c->pid) return;
-
-       pthread_barrier_init(&c->barrier, 0, c->cnt);
-       for (tp=c->list; tp; tp=tp->next)
-               if (__uniclone(tp->stack, restart_thread, tp->td) < 0)
-                       _exit(127);
-       pthread_barrier_wait(&c->barrier);
-}
-
-pid_t forkall()
-{
-       struct ctx c = { .caller = pthread_self() };
-       __synccall(do_forkall, &c);
-       return c.pid;
-}
-#endif
index 2cd25e4bb2b84315ca4adb9c562d4592eebcb55a..1520b3b40b582855e27b394120500fb32ddb5d0a 100644 (file)
@@ -47,14 +47,6 @@ static void handler(int sig, siginfo_t *si, void *ctx)
        errno = old_errno;
 }
 
-void __synccall_wait()
-{
-       struct chain *ch = cur;
-       sem_post(&ch->sem2);
-       while (sem_wait(&ch->sem));
-       sem_post(&ch->sem);
-}
-
 void __synccall(void (*func)(void *), void *ctx)
 {
        pthread_t self;