From 7852e2095b8c4018b22a2a9a4fd458e119fbae4e Mon Sep 17 00:00:00 2001 From: davidxu Date: Wed, 1 Sep 2010 03:55:10 +0000 Subject: pthread_atfork should acquire writer lock and protect the code with critical region. --- lib/libthr/thread/thr_fork.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/libthr/thread/thr_fork.c') 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); } -- cgit v1.1