diff options
author | davidxu <davidxu@FreeBSD.org> | 2010-09-01 03:55:10 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2010-09-01 03:55:10 +0000 |
commit | 7852e2095b8c4018b22a2a9a4fd458e119fbae4e (patch) | |
tree | 56606105837711e396764bbc206544907bffc0cf /lib/libthr/thread/thr_fork.c | |
parent | 5f00b957aee7c4cc6138734e4b4dc582cf4d10f9 (diff) | |
download | FreeBSD-src-7852e2095b8c4018b22a2a9a4fd458e119fbae4e.zip FreeBSD-src-7852e2095b8c4018b22a2a9a4fd458e119fbae4e.tar.gz |
pthread_atfork should acquire writer lock and protect the code
with critical region.
Diffstat (limited to 'lib/libthr/thread/thr_fork.c')
-rw-r--r-- | lib/libthr/thread/thr_fork.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/libthr/thread/thr_fork.c b/lib/libthr/thread/thr_fork.c index 1ce7c6e..c70096e 100644 --- a/lib/libthr/thread/thr_fork.c +++ b/lib/libthr/thread/thr_fork.c @@ -89,9 +89,11 @@ _pthread_atfork(void (*prepare)(void), void (*parent)(void), af->prepare = prepare; af->parent = parent; af->child = child; - _thr_rwl_rdlock(&_thr_atfork_lock); + THR_CRITICAL_ENTER(curthread); + _thr_rwl_wrlock(&_thr_atfork_lock); TAILQ_INSERT_TAIL(&_thr_atfork_list, af, qe); _thr_rwl_unlock(&_thr_atfork_lock); + THR_CRITICAL_LEAVE(curthread); return (0); } |