From e0fcbebd9df209452022378d54c13344b4167d29 Mon Sep 17 00:00:00 2001 From: rpj Date: Tue, 5 Jun 2001 02:29:09 +0000 Subject: Update some comments. --- mutex.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'mutex.c') diff --git a/mutex.c b/mutex.c index 6c64cd5..086c0bc 100644 --- a/mutex.c +++ b/mutex.c @@ -174,15 +174,19 @@ 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. Is this correct? + */ if (result == 0 || pthread_equal( mx->ownerThread, pthread_self() ) ) { - /* * FIXME!!! * The mutex isn't held by another thread but we could still - * be too late invalidating the mutex below. Yet we can't do it - * earlier in case another thread needs to unlock the mutex - * that it's holding. + * be too late invalidating the mutex below since another thread + * may alredy have entered mutex_lock and the check for a valid + * *mutex != NULL. */ *mutex = NULL; -- cgit v1.2.3