From owner-svn-src-head@FreeBSD.ORG Wed Sep 1 07:09:47 2010 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 13E1D10656B0; Wed, 1 Sep 2010 07:09:47 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 033E78FC19; Wed, 1 Sep 2010 07:09:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8179knH054706; Wed, 1 Sep 2010 07:09:46 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8179kCP054704; Wed, 1 Sep 2010 07:09:46 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201009010709.o8179kCP054704@svn.freebsd.org> From: David Xu Date: Wed, 1 Sep 2010 07:09:46 +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: r212083 - 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: Wed, 01 Sep 2010 07:09:47 -0000 Author: davidxu Date: Wed Sep 1 07:09:46 2010 New Revision: 212083 URL: http://svn.freebsd.org/changeset/base/212083 Log: In function __pthread_cxa_finalize(), also make code for removing atfork handler be async-signal safe. 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 06:51:42 2010 (r212082) +++ head/lib/libthr/thread/thr_fork.c Wed Sep 1 07:09:46 2010 (r212083) @@ -100,22 +100,29 @@ _pthread_atfork(void (*prepare)(void), v void __pthread_cxa_finalize(struct dl_phdr_info *phdr_info) { + atfork_head temp_list = TAILQ_HEAD_INITIALIZER(temp_list); struct pthread *curthread; struct pthread_atfork *af, *af1; _thr_check_init(); curthread = _get_curthread(); + THR_CRITICAL_ENTER(curthread); _thr_rwl_wrlock(&_thr_atfork_lock); TAILQ_FOREACH_SAFE(af, &_thr_atfork_list, qe, af1) { if (__elf_phdr_match_addr(phdr_info, af->prepare) || __elf_phdr_match_addr(phdr_info, af->parent) || __elf_phdr_match_addr(phdr_info, af->child)) { TAILQ_REMOVE(&_thr_atfork_list, af, qe); - free(af); + TAILQ_INSERT_TAIL(&temp_list, af, qe); } } _thr_rwl_unlock(&_thr_atfork_lock); + THR_CRITICAL_LEAVE(curthread); + while ((af = TAILQ_FIRST(&temp_list)) != NULL) { + TAILQ_REMOVE(&temp_list, af, qe); + free(af); + } _thr_tsd_unload(phdr_info); _thr_sigact_unload(phdr_info); }