svn commit: r212078 - head/lib/libthr/thread

David Xu davidxu at FreeBSD.org
Wed Sep 1 03:55:11 UTC 2010


Author: davidxu
Date: Wed Sep  1 03:55:10 2010
New Revision: 212078
URL: http://svn.freebsd.org/changeset/base/212078

Log:
  pthread_atfork should acquire writer lock and protect the code
  with critical region.

Modified:
  head/lib/libthr/thread/thr_fork.c

Modified: head/lib/libthr/thread/thr_fork.c
==============================================================================
--- head/lib/libthr/thread/thr_fork.c	Wed Sep  1 03:11:21 2010	(r212077)
+++ head/lib/libthr/thread/thr_fork.c	Wed Sep  1 03:55:10 2010	(r212078)
@@ -89,9 +89,11 @@ _pthread_atfork(void (*prepare)(void), v
 	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);
 }
 


More information about the svn-src-head mailing list