diff options
author | davidxu <davidxu@FreeBSD.org> | 2006-01-03 13:30:23 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2006-01-03 13:30:23 +0000 |
commit | 46ad9344c29488518dcba45412d50b029733bcc9 (patch) | |
tree | 9903082f77193e36e459d866bc7902c830a5060e /lib/libthr/thread/thr_fork.c | |
parent | 428f554873ce3fe7c4e07271e411bd21584cc74d (diff) | |
download | FreeBSD-src-46ad9344c29488518dcba45412d50b029733bcc9.zip FreeBSD-src-46ad9344c29488518dcba45412d50b029733bcc9.tar.gz |
Remove in-progress wait code to sync with libpthread's behavior.
Diffstat (limited to 'lib/libthr/thread/thr_fork.c')
-rw-r--r-- | lib/libthr/thread/thr_fork.c | 38 |
1 files changed, 8 insertions, 30 deletions
diff --git a/lib/libthr/thread/thr_fork.c b/lib/libthr/thread/thr_fork.c index 8b311cb..4c222d9 100644 --- a/lib/libthr/thread/thr_fork.c +++ b/lib/libthr/thread/thr_fork.c @@ -105,10 +105,6 @@ __weak_reference(_fork, fork); pid_t _fork(void) { - static umtx_t inprogress; - static int waiters; - umtx_t tmp; - struct pthread *curthread; struct pthread_atfork *af; pid_t ret; @@ -120,25 +116,7 @@ _fork(void) curthread = _get_curthread(); - /* - * Block all signals until we reach a safe point. - */ - _thr_signal_block(curthread); - THR_UMTX_LOCK(curthread, &_thr_atfork_lock); - tmp = inprogress; - while (tmp) { - waiters++; - THR_UMTX_UNLOCK(curthread, &_thr_atfork_lock); - _thr_umtx_wait(&inprogress, tmp, NULL); - THR_UMTX_LOCK(curthread, &_thr_atfork_lock); - waiters--; - tmp = inprogress; - } - inprogress = 1; - - /* Unlock mutex, allow new hook to be added during executing hooks. */ - THR_UMTX_UNLOCK(curthread, &_thr_atfork_lock); /* Run down atfork prepare handlers. */ TAILQ_FOREACH_REVERSE(af, &_thr_atfork_list, atfork_head, qe) { @@ -158,11 +136,15 @@ _fork(void) unlock_malloc = 0; } + /* + * Block all signals until we reach a safe point. + */ + _thr_signal_block(curthread); + /* Fork a new process: */ if ((ret = __sys_fork()) == 0) { /* Child process */ errsave = errno; - inprogress = 0; curthread->cancelflags &= ~THR_CANCEL_NEEDED; /* * Thread list will be reinitialized, and later we call @@ -197,22 +179,18 @@ _fork(void) /* Parent process */ errsave = errno; - if (unlock_malloc) - _spinunlock(__malloc_lock); - /* Ready to continue, unblock signals. */ _thr_signal_unblock(curthread); + if (unlock_malloc) + _spinunlock(__malloc_lock); + /* Run down atfork parent handlers. */ TAILQ_FOREACH(af, &_thr_atfork_list, qe) { if (af->parent != NULL) af->parent(); } - THR_UMTX_LOCK(curthread, &_thr_atfork_lock); - inprogress = 0; - if (waiters) - _thr_umtx_wake(&inprogress, waiters); THR_UMTX_UNLOCK(curthread, &_thr_atfork_lock); } errno = errsave; |