diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2015-10-18 08:02:59 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2015-10-18 08:02:59 +0000 |
commit | 6fc3a6915677c8ab3e4d29f9774508161a86873f (patch) | |
tree | ae4ed50b84a4137db8cd9d3174bd86678d1cfc6a | |
parent | 70a1964caf5e624749b1a2ca719f7932c69714a7 (diff) |
ld.so no longer needs or uses a bind lock, so stop setting it. This
eliminates a chunk of complexity from the libpthread init and the fork
wrapper, as it was the bind lock that needed prebinding before use.
-rw-r--r-- | lib/librthread/rthread.c | 24 | ||||
-rw-r--r-- | lib/librthread/rthread.h | 3 | ||||
-rw-r--r-- | lib/librthread/rthread_fork.c | 26 |
3 files changed, 5 insertions, 48 deletions
diff --git a/lib/librthread/rthread.c b/lib/librthread/rthread.c index aff3817f42c..c0c692d021b 100644 --- a/lib/librthread/rthread.c +++ b/lib/librthread/rthread.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rthread.c,v 1.83 2015/05/19 20:50:06 guenther Exp $ */ +/* $OpenBSD: rthread.c,v 1.84 2015/10/18 08:02:58 guenther Exp $ */ /* * Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org> * All Rights Reserved. @@ -207,18 +207,7 @@ _rthread_init(void) #ifndef NO_PIC if (_DYNAMIC) { - /* - * To avoid recursion problems in ld.so, we need to trigger the - * functions once to fully bind them before registering them - * for use. - */ - _rthread_dl_lock(0); - _rthread_dl_lock(1); - _rthread_bind_lock(0); - _rthread_bind_lock(1); - sched_yield(); dlctl(NULL, DL_SETTHREADLCK, _rthread_dl_lock); - dlctl(NULL, DL_SETBINDLCK, _rthread_bind_lock); } #endif @@ -709,17 +698,6 @@ _rthread_dl_lock(int what) TAILQ_INIT(&lockers); } } - -void -_rthread_bind_lock(int what) -{ - static struct _spinlock lock = _SPINLOCK_UNLOCKED; - - if (what == 0) - _spinlock(&lock); - else - _spinunlock(&lock); -} #endif diff --git a/lib/librthread/rthread.h b/lib/librthread/rthread.h index 7176252353a..177f31db242 100644 --- a/lib/librthread/rthread.h +++ b/lib/librthread/rthread.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rthread.h,v 1.52 2015/05/19 20:50:06 guenther Exp $ */ +/* $OpenBSD: rthread.h,v 1.53 2015/10/18 08:02:58 guenther Exp $ */ /* * Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org> * All Rights Reserved. @@ -221,7 +221,6 @@ void _rthread_debug(int, const char *, ...) void _rthread_debug_init(void); #ifndef NO_PIC void _rthread_dl_lock(int what); -void _rthread_bind_lock(int); #endif /* rthread_cancel.c */ diff --git a/lib/librthread/rthread_fork.c b/lib/librthread/rthread_fork.c index a1cda56f76f..18121278325 100644 --- a/lib/librthread/rthread_fork.c +++ b/lib/librthread/rthread_fork.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rthread_fork.c,v 1.13 2015/05/19 20:50:06 guenther Exp $ */ +/* $OpenBSD: rthread_fork.c,v 1.14 2015/10/18 08:02:58 guenther Exp $ */ /* * Copyright (c) 2008 Kurt Miller <kurt@openbsd.org> @@ -40,7 +40,6 @@ #include <pthread.h> #include <stdlib.h> #include <unistd.h> -#include <signal.h> #include "thread_private.h" /* in libc/include */ @@ -56,9 +55,6 @@ _dofork(int is_vfork) pthread_t me; pid_t (*sys_fork)(void); pid_t newid; -#ifndef NO_PIC - sigset_t nmask, omask; -#endif sys_fork = is_vfork ? &_thread_sys_vfork : &_thread_sys_fork; @@ -70,9 +66,8 @@ _dofork(int is_vfork) /* * Protect important libc/ld.so critical areas across the fork call. * dlclose() will grab the atexit lock via __cxa_finalize() so lock - * the dl_lock first. malloc()/free() can grab the arc4 lock so lock - * malloc_lock first. Finally lock the bind_lock last so that any lazy - * binding in the other locking functions can succeed. + * the dl_lock first. malloc()/free() can use arc4random(), so lock + * malloc_lock before arc4_lock */ #ifndef NO_PIC @@ -84,23 +79,8 @@ _dofork(int is_vfork) _thread_malloc_lock(); _thread_arc4_lock(); -#ifndef NO_PIC - if (_DYNAMIC) { - sigfillset(&nmask); - _thread_sys_sigprocmask(SIG_BLOCK, &nmask, &omask); - _rthread_bind_lock(0); - } -#endif - newid = sys_fork(); -#ifndef NO_PIC - if (_DYNAMIC) { - _rthread_bind_lock(1); - _thread_sys_sigprocmask(SIG_SETMASK, &omask, NULL); - } -#endif - _thread_arc4_unlock(); _thread_malloc_unlock(); _thread_atexit_unlock(); |