From db171f2f9435b98f05f33fcbc0dcf0c5cc1cb917 Mon Sep 17 00:00:00 2001 From: rpj Date: Thu, 24 Mar 2011 23:33:14 +0000 Subject: First pass of robust mutexes --- pthread_mutex_destroy.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'pthread_mutex_destroy.c') diff --git a/pthread_mutex_destroy.c b/pthread_mutex_destroy.c index c9460dc..7b8c9cd 100644 --- a/pthread_mutex_destroy.c +++ b/pthread_mutex_destroy.c @@ -61,7 +61,7 @@ pthread_mutex_destroy (pthread_mutex_t * mutex) * If trylock succeeded and the mutex is not recursively locked it * can be destroyed. */ - if (result == 0) + if (0 == result || ENOTRECOVERABLE == result) { if (mx->kind != PTHREAD_MUTEX_RECURSIVE || 1 == mx->recursive_count) { @@ -74,10 +74,14 @@ pthread_mutex_destroy (pthread_mutex_t * mutex) */ *mutex = NULL; - result = pthread_mutex_unlock (&mx); + result = (0 == result)?pthread_mutex_unlock(&mx):0; - if (result == 0) + if (0 == result) { + if (mx->robustNode != NULL) + { + free(mx->robustNode); + } if (!CloseHandle (mx->event)) { *mutex = mx; -- cgit v1.2.3