Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Sep 2010 07:09:46 +0000 (UTC)
From:      David Xu <davidxu@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r212083 - head/lib/libthr/thread
Message-ID:  <201009010709.o8179kCP054704@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201009010709.o8179kCP054704>