From 52c1047709bbc61fa793bcc6a28daabea88d2a20 Mon Sep 17 00:00:00 2001 From: rpj Date: Wed, 11 Dec 2002 00:40:17 +0000 Subject: 2002-12-11 Thomas Pfaff * pthread_mutex_trylock.c: Should return EBUSY rather than EDEADLK. * pthread_mutex_destroy.c: Remove redundant ownership test (the trylock call does this for us); do not destroy a recursively locked mutex. --- pthread_mutex_destroy.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'pthread_mutex_destroy.c') diff --git a/pthread_mutex_destroy.c b/pthread_mutex_destroy.c index 22d78a1..e217bec 100644 --- a/pthread_mutex_destroy.c +++ b/pthread_mutex_destroy.c @@ -60,17 +60,10 @@ pthread_mutex_destroy(pthread_mutex_t *mutex) result = pthread_mutex_trylock(&mx); /* - * The mutex type may not be RECURSIVE therefore trylock may return EBUSY if - * we already own the mutex. Here we are assuming that it's OK to destroy - * a mutex that we own and have locked recursively. - * - * For FAST mutexes we record the owner as ANONYMOUS for speed. In this - * case we assume that the thread calling pthread_mutex_destroy() is the - * owner, if the mutex is owned at all. + * If trylock succeeded and the mutex is not recursively locked it + * can be destroyed. */ - if (result == 0 - || mx->ownerThread == (pthread_t) PTW32_MUTEX_OWNER_ANONYMOUS - || pthread_equal( mx->ownerThread, pthread_self() ) ) + if (result == 0 && 1 == mx->recursive_count) { /* * FIXME!!! -- cgit v1.2.3