From 1478c2de052374c6356db5513749a144c13791b1 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Thu, 7 Dec 2006 23:24:02 +0000 Subject: Major cleanup of internal mutex locking. Be more consistant in how we do things, and avoid potential deadlocks caused when a thread holding a uClibc internal lock get canceled and terminates without releasing the lock. This change also provides a single place, bits/uClibc_mutex.h, for thread libraries to modify to change all instances of internal locking. --- libc/stdlib/abort.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'libc/stdlib/abort.c') diff --git a/libc/stdlib/abort.c b/libc/stdlib/abort.c index a940768c0..6e1806eae 100644 --- a/libc/stdlib/abort.c +++ b/libc/stdlib/abort.c @@ -49,12 +49,8 @@ extern void weak_function _stdio_term(void) attribute_hidden; static int been_there_done_that = 0; /* Be prepared in case multiple threads try to abort() */ -#ifdef __UCLIBC_HAS_THREADS__ -# include -static pthread_mutex_t mylock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; -#endif -#define LOCK __pthread_mutex_lock(&mylock) -#define UNLOCK __pthread_mutex_unlock(&mylock) +#include +__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP); /* Cause an abnormal program termination with core-dump */ void abort(void) @@ -62,7 +58,7 @@ void abort(void) sigset_t sigs; /* Make sure we acquire the lock before proceeding */ - LOCK; + __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE(mylock); /* Unmask SIGABRT to be sure we can get it */ if (__sigemptyset(&sigs) == 0 && __sigaddset(&sigs, SIGABRT) == 0) { @@ -85,9 +81,9 @@ void abort(void) #endif abort_it: - UNLOCK; + __UCLIBC_MUTEX_UNLOCK_CANCEL_UNSAFE(mylock); raise(SIGABRT); - LOCK; + __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE(mylock); } /* Still here? Try to remove any signal handlers */ -- cgit v1.2.3