From owner-svn-src-head@FreeBSD.ORG Mon May 11 16:45:53 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9D15D1065675; Mon, 11 May 2009 16:45:53 +0000 (UTC) (envelope-from green@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8B0238FC1C; Mon, 11 May 2009 16:45:53 +0000 (UTC) (envelope-from green@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4BGjrQP096615; Mon, 11 May 2009 16:45:53 GMT (envelope-from green@svn.freebsd.org) Received: (from green@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4BGjrX0096614; Mon, 11 May 2009 16:45:53 GMT (envelope-from green@svn.freebsd.org) Message-Id: <200905111645.n4BGjrX0096614@svn.freebsd.org> From: Brian Feldman Date: Mon, 11 May 2009 16:45:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r191993 - head/lib/libthr/thread X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 May 2009 16:45:54 -0000 Author: green Date: Mon May 11 16:45:53 2009 New Revision: 191993 URL: http://svn.freebsd.org/changeset/base/191993 Log: These are some cosmetic changes to improve the clarity of libthr's fork implementation. Modified: head/lib/libthr/thread/thr_fork.c Modified: head/lib/libthr/thread/thr_fork.c ============================================================================== --- head/lib/libthr/thread/thr_fork.c Mon May 11 16:37:31 2009 (r191992) +++ head/lib/libthr/thread/thr_fork.c Mon May 11 16:45:53 2009 (r191993) @@ -105,7 +105,7 @@ _fork(void) struct pthread_atfork *af; pid_t ret; int errsave; - int unlock_malloc; + int was_threaded; int rtld_locks[MAX_RTLD_LOCKS]; if (!_thr_is_inited()) @@ -122,16 +122,16 @@ _fork(void) } /* - * Try our best to protect memory from being corrupted in - * child process because another thread in malloc code will - * simply be kill by fork(). + * All bets are off as to what should happen soon if the parent + * process was not so kindly as to set up pthread fork hooks to + * relinquish all running threads. */ if (_thr_isthreaded() != 0) { - unlock_malloc = 1; + was_threaded = 1; _malloc_prefork(); _rtld_atfork_pre(rtld_locks); } else { - unlock_malloc = 0; + was_threaded = 0; } /* @@ -159,7 +159,7 @@ _fork(void) _thr_umutex_init(&curthread->lock); _thr_umutex_init(&_thr_atfork_lock); - if (unlock_malloc) + if (was_threaded) _rtld_atfork_post(rtld_locks); _thr_setthreaded(0); @@ -173,7 +173,7 @@ _fork(void) /* Ready to continue, unblock signals. */ _thr_signal_unblock(curthread); - if (unlock_malloc) { + if (was_threaded) { __isthreaded = 1; _malloc_postfork(); __isthreaded = 0; @@ -191,7 +191,7 @@ _fork(void) /* Ready to continue, unblock signals. */ _thr_signal_unblock(curthread); - if (unlock_malloc) { + if (was_threaded) { _rtld_atfork_post(rtld_locks); _malloc_postfork(); }