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);
 }
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to