diff options
author | David Xu <davidxu@FreeBSD.org> | 2010-09-01 03:55:10 +0000 |
---|---|---|
committer | David Xu <davidxu@FreeBSD.org> | 2010-09-01 03:55:10 +0000 |
commit | a523216bc6c82fe915d2d1188029d01784db0d5d (patch) | |
tree | 56606105837711e396764bbc206544907bffc0cf /lib | |
parent | ada33a6e3629051aabc54ba3d1fa13d0ae82262b (diff) | |
download | src-a523216bc6c82fe915d2d1188029d01784db0d5d.tar.gz src-a523216bc6c82fe915d2d1188029d01784db0d5d.zip |
pthread_atfork should acquire writer lock and protect the code
with critical region.
Notes
Notes:
svn path=/head/; revision=212078
Diffstat (limited to 'lib')
-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 1ce7c6eb4ae8..c70096ea6421 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); } |