diff options
author | Konstantin Belousov <kib@FreeBSD.org> | 2016-03-21 06:52:35 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2016-03-21 06:52:35 +0000 |
commit | 53fd961f050e888c7882c314b8dc8a0d100759bf (patch) | |
tree | 144ad6be72345b1199265c0c479ee3531a129f78 /lib/libthr | |
parent | 07f22a288d60694ac7305c64323e1d53f0f2cc0d (diff) | |
download | src-test2-53fd961f050e888c7882c314b8dc8a0d100759bf.tar.gz src-test2-53fd961f050e888c7882c314b8dc8a0d100759bf.zip |
Notes
Diffstat (limited to 'lib/libthr')
-rw-r--r-- | lib/libthr/thread/thr_fork.c | 6 | ||||
-rw-r--r-- | lib/libthr/thread/thr_init.c | 2 | ||||
-rw-r--r-- | lib/libthr/thread/thr_private.h | 2 | ||||
-rw-r--r-- | lib/libthr/thread/thr_pshared.c | 14 |
4 files changed, 22 insertions, 2 deletions
diff --git a/lib/libthr/thread/thr_fork.c b/lib/libthr/thread/thr_fork.c index 7256b68b7a3f..531e09cef5f1 100644 --- a/lib/libthr/thread/thr_fork.c +++ b/lib/libthr/thread/thr_fork.c @@ -168,6 +168,7 @@ __thr_fork(void) if (_thr_isthreaded() != 0) { was_threaded = 1; _malloc_prefork(); + __thr_pshared_atfork_pre(); _rtld_atfork_pre(rtld_locks); } else { was_threaded = 0; @@ -202,8 +203,10 @@ __thr_fork(void) _thr_signal_postfork_child(); - if (was_threaded) + if (was_threaded) { _rtld_atfork_post(rtld_locks); + __thr_pshared_atfork_post(); + } _thr_setthreaded(0); /* reinitalize library. */ @@ -236,6 +239,7 @@ __thr_fork(void) if (was_threaded) { _rtld_atfork_post(rtld_locks); + __thr_pshared_atfork_post(); _malloc_postfork(); } diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c index b0f4c5e87c8d..f9f845b4c3f8 100644 --- a/lib/libthr/thread/thr_init.c +++ b/lib/libthr/thread/thr_init.c @@ -445,7 +445,6 @@ init_private(void) _thr_once_init(); _thr_spinlock_init(); _thr_list_init(); - __thr_pshared_init(); _thr_wake_addr_init(); _sleepq_init(); _single_thread = NULL; @@ -456,6 +455,7 @@ init_private(void) * e.g. after a fork(). */ if (init_once == 0) { + __thr_pshared_init(); /* Find the stack top */ mib[0] = CTL_KERN; mib[1] = KERN_USRSTACK; diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h index 31f8e6c863da..7ee1fbf94a16 100644 --- a/lib/libthr/thread/thr_private.h +++ b/lib/libthr/thread/thr_private.h @@ -952,6 +952,8 @@ void _tcb_dtor(struct tcb *); void __thr_pshared_init(void) __hidden; void *__thr_pshared_offpage(void *key, int doalloc) __hidden; void __thr_pshared_destroy(void *key) __hidden; +void __thr_pshared_atfork_pre(void) __hidden; +void __thr_pshared_atfork_post(void) __hidden; __END_DECLS diff --git a/lib/libthr/thread/thr_pshared.c b/lib/libthr/thread/thr_pshared.c index e8ccf1cebb10..83714785f9b1 100644 --- a/lib/libthr/thread/thr_pshared.c +++ b/lib/libthr/thread/thr_pshared.c @@ -252,3 +252,17 @@ __thr_pshared_destroy(void *key) pshared_clean(key, val); pshared_gc(curthread); } + +void +__thr_pshared_atfork_pre(void) +{ + + _thr_rwl_rdlock(&pshared_lock); +} + +void +__thr_pshared_atfork_post(void) +{ + + _thr_rwl_unlock(&pshared_lock); +} |