From a5b13ff571d8e5b6e117756821e8aa5beb7b5d2c Mon Sep 17 00:00:00 2001 From: deischen Date: Sat, 18 Dec 2004 18:07:37 +0000 Subject: Use a generic way to back threads out of wait queues when handling signals instead of having more intricate knowledge of thread state within signal handling. Simplify signal code because of above (by David Xu). Use macros for libpthread usage of pthread_cleanup_push() and pthread_cleanup_pop(). This removes some instances of malloc() and free() from the semaphore and pthread_once() implementations. When single threaded and forking(), make sure that the current thread's signal mask is inherited by the forked thread. Use private mutexes for libc and libpthread. Signals are deferred while threads hold private mutexes. This fix also breaks www/linuxpluginwrapper; a patch that fixes it is at http://people.freebsd.org/~deischen/kse/linuxpluginwrapper.diff Fix race condition in condition variables where handling a signal (pthread_kill() or kill()) may not see a wakeup (pthread_cond_signal() or pthread_cond_broadcast()). In collaboration with: davidxu --- lib/libpthread/thread/thr_clean.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/libpthread/thread/thr_clean.c') diff --git a/lib/libpthread/thread/thr_clean.c b/lib/libpthread/thread/thr_clean.c index a8cedb4..1da8a6b 100644 --- a/lib/libpthread/thread/thr_clean.c +++ b/lib/libpthread/thread/thr_clean.c @@ -50,6 +50,7 @@ _pthread_cleanup_push(void (*routine) (void *), void *routine_arg) malloc(sizeof(struct pthread_cleanup))) != NULL) { new->routine = routine; new->routine_arg = routine_arg; + new->onstack = 0; new->next = curthread->cleanup; curthread->cleanup = new; @@ -67,6 +68,7 @@ _pthread_cleanup_pop(int execute) if (execute) { old->routine(old->routine_arg); } - free(old); + if (old->onstack == 0) + free(old); } } -- cgit v1.1