diff options
author | Neal H. Walfield <neal@gnu.org> | 2008-06-22 09:05:31 +0000 |
---|---|---|
committer | Neal H. Walfield <neal@gnu.org> | 2008-06-22 09:05:31 +0000 |
commit | 362912127aa75b78d4f42493ee1783bab9135cd1 (patch) | |
tree | 612fc3ddaa1826199afdbe8d8189e1b3898f4bb6 /sysdeps/generic/pt-mutex-unlock.c | |
parent | 9830b3b2eb53aa7ad2eeb4cc11fbb44ba323cf4e (diff) |
2008-06-22 Neal H. Walfield <neal@gnu.org>
* sysdeps/generic/pt-mutex-timedlock.c
(__pthread_mutex_timedlock_internal) [! NDEBUG]: Set MUTEX->OWNER
appropriately and assert that it is consistent.
* sysdeps/generic/pt-mutex-unlock.c (__pthread_mutex_unlock) [!
NDEBUG]: Set MUTEX->OWNER appropriately and assert that it is
consistent.
* sysdeps/generic/pt-mutex-trylock.c (__pthread_mutex_trylock) [!
NDEBUG]: Set MUTEX->OWNER.
Diffstat (limited to 'sysdeps/generic/pt-mutex-unlock.c')
-rw-r--r-- | sysdeps/generic/pt-mutex-unlock.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/sysdeps/generic/pt-mutex-unlock.c b/sysdeps/generic/pt-mutex-unlock.c index 2f719d3..d2a4257 100644 --- a/sysdeps/generic/pt-mutex-unlock.c +++ b/sysdeps/generic/pt-mutex-unlock.c @@ -1,5 +1,5 @@ /* Unlock a mutex. Generic version. - Copyright (C) 2000,02 Free Software Foundation, Inc. + Copyright (C) 2000, 2002, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -31,12 +31,25 @@ __pthread_mutex_unlock (pthread_mutex_t *mutex) __pthread_spin_lock (&mutex->__lock); - if (mutex->attr) + if (! mutex->attr || mutex->attr->mutex_type == PTHREAD_MUTEX_NORMAL) + { +#ifndef NDEBUG + if (_pthread_self ()) + { + assert (mutex->owner); + assertx (mutex->owner == _pthread_self (), + "%p(%x) != %p(%x)", + mutex->owner, + ((struct __pthread *) mutex->owner)->threadid, + _pthread_self (), + _pthread_self ()->threadid); + mutex->owner = NULL; + } +#endif + } + else switch (mutex->attr->mutex_type) { - case PTHREAD_MUTEX_NORMAL: - break; - case PTHREAD_MUTEX_ERRORCHECK: case PTHREAD_MUTEX_RECURSIVE: if (mutex->owner != _pthread_self ()) @@ -59,6 +72,7 @@ __pthread_mutex_unlock (pthread_mutex_t *mutex) LOSE; } + if (mutex->__queue == NULL) { __pthread_spin_unlock (&mutex->__held); @@ -69,6 +83,10 @@ __pthread_mutex_unlock (pthread_mutex_t *mutex) wakeup = mutex->__queue; __pthread_dequeue (wakeup); +#ifndef NDEBUG + mutex->owner = wakeup; +#endif + /* We do not unlock MUTEX->held: we are transferring the ownership to the thread that we are waking up. */ |