Spotted by "daste": When unlocking the mutex owner must be set to -1
also for error check mutexes, otherwise the next pthread_mutex_lock() will fail. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28428 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
1ecbbd9c27
commit
8d41d0ee72
@ -160,13 +160,13 @@ pthread_mutex_unlock(pthread_mutex_t *mutex)
|
||||
if (mutex->owner != find_thread(NULL))
|
||||
return EPERM;
|
||||
|
||||
if (MUTEX_TYPE(mutex) == PTHREAD_MUTEX_RECURSIVE) {
|
||||
if (mutex->owner_count-- > 1)
|
||||
return B_OK;
|
||||
|
||||
mutex->owner = -1;
|
||||
if (MUTEX_TYPE(mutex) == PTHREAD_MUTEX_RECURSIVE
|
||||
&& mutex->owner_count-- > 1) {
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
mutex->owner = -1;
|
||||
|
||||
if (atomic_add((vint32*)&mutex->count, -1) > 1)
|
||||
return release_sem(mutex->sem);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user