aboutsummaryrefslogtreecommitdiff
path: root/nptl/pthread_mutex_unlock.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2006-02-17 16:15:56 +0000
committerJakub Jelinek <jakub@redhat.com>2006-02-17 16:15:56 +0000
commit9c09cd93597a91d6b0b59c8813be97d530e7551c (patch)
treecd7ea8e6dc157e92ffd5f20dfa997e8be5b7da8b /nptl/pthread_mutex_unlock.c
parent7d8db4cd587349f485fb85f4bea9e3011a3e55d7 (diff)
downloadglibc-9c09cd93597a91d6b0b59c8813be97d530e7551c.tar
glibc-9c09cd93597a91d6b0b59c8813be97d530e7551c.tar.gz
glibc-9c09cd93597a91d6b0b59c8813be97d530e7551c.tar.bz2
glibc-9c09cd93597a91d6b0b59c8813be97d530e7551c.zip
Updated to fedora-glibc-20060217T1609
Diffstat (limited to 'nptl/pthread_mutex_unlock.c')
-rw-r--r--nptl/pthread_mutex_unlock.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/nptl/pthread_mutex_unlock.c b/nptl/pthread_mutex_unlock.c
index 4d87381065..d41eefe34c 100644
--- a/nptl/pthread_mutex_unlock.c
+++ b/nptl/pthread_mutex_unlock.c
@@ -41,23 +41,32 @@ __pthread_mutex_unlock_usercnt (mutex, decr)
if (--mutex->__data.__count != 0)
/* We still hold the mutex. */
return 0;
- break;
+ goto normal;
case PTHREAD_MUTEX_ERRORCHECK_NP:
/* Error checking mutex. */
if (mutex->__data.__owner != THREAD_GETMEM (THREAD_SELF, tid)
|| ! lll_mutex_islocked (mutex->__data.__lock))
return EPERM;
- break;
+ /* FALLTHROUGH */
case PTHREAD_MUTEX_TIMED_NP:
case PTHREAD_MUTEX_ADAPTIVE_NP:
- /* Normal mutex. Nothing special to do. */
+ /* Always reset the owner field. */
+ normal:
+ mutex->__data.__owner = 0;
+ if (decr)
+ /* One less user. */
+ --mutex->__data.__nusers;
+
+ /* Unlock. */
+ lll_mutex_unlock (mutex->__data.__lock);
break;
case PTHREAD_MUTEX_ROBUST_PRIVATE_RECURSIVE_NP:
/* Recursive mutex. */
- if (mutex->__data.__owner == -THREAD_GETMEM (THREAD_SELF, tid))
+ if ((mutex->__data.__lock & FUTEX_TID_MASK)
+ == THREAD_GETMEM (THREAD_SELF, tid))
{
if (--mutex->__data.__count != 0)
/* We still hold the mutex. */
@@ -78,7 +87,8 @@ __pthread_mutex_unlock_usercnt (mutex, decr)
case PTHREAD_MUTEX_ROBUST_PRIVATE_ERRORCHECK_NP:
case PTHREAD_MUTEX_ROBUST_PRIVATE_NP:
case PTHREAD_MUTEX_ROBUST_PRIVATE_ADAPTIVE_NP:
- if (abs (mutex->__data.__owner) != THREAD_GETMEM (THREAD_SELF, tid)
+ if ((mutex->__data.__lock & FUTEX_TID_MASK)
+ != THREAD_GETMEM (THREAD_SELF, tid)
|| ! lll_mutex_islocked (mutex->__data.__lock))
return EPERM;
@@ -86,15 +96,21 @@ __pthread_mutex_unlock_usercnt (mutex, decr)
making the state consistent, mark the mutex as unrecoverable
and make all waiters. */
if (__builtin_expect (mutex->__data.__owner
- == -THREAD_GETMEM (THREAD_SELF, tid)
- || (mutex->__data.__owner
- == PTHREAD_MUTEX_NOTRECOVERABLE), 0))
+ == PTHREAD_MUTEX_INCONSISTENT, 0))
notrecoverable:
newowner = PTHREAD_MUTEX_NOTRECOVERABLE;
robust:
/* Remove mutex from the list. */
DEQUEUE_MUTEX (mutex);
+
+ mutex->__data.__owner = newowner;
+ if (decr)
+ /* One less user. */
+ --mutex->__data.__nusers;
+
+ /* Unlock. */
+ lll_robust_mutex_unlock (mutex->__data.__lock);
break;
default:
@@ -102,15 +118,6 @@ __pthread_mutex_unlock_usercnt (mutex, decr)
return EINVAL;
}
- /* Always reset the owner field. */
- mutex->__data.__owner = newowner;
- if (decr)
- /* One less user. */
- --mutex->__data.__nusers;
-
- /* Unlock. */
- lll_mutex_unlock (mutex->__data.__lock);
-
return 0;
}