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:
@@ -160,13 +160,13 @@ pthread_mutex_unlock(pthread_mutex_t *mutex)
|
|||||||
if (mutex->owner != find_thread(NULL))
|
if (mutex->owner != find_thread(NULL))
|
||||||
return EPERM;
|
return EPERM;
|
||||||
|
|
||||||
if (MUTEX_TYPE(mutex) == PTHREAD_MUTEX_RECURSIVE) {
|
if (MUTEX_TYPE(mutex) == PTHREAD_MUTEX_RECURSIVE
|
||||||
if (mutex->owner_count-- > 1)
|
&& mutex->owner_count-- > 1) {
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
mutex->owner = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mutex->owner = -1;
|
||||||
|
|
||||||
if (atomic_add((vint32*)&mutex->count, -1) > 1)
|
if (atomic_add((vint32*)&mutex->count, -1) > 1)
|
||||||
return release_sem(mutex->sem);
|
return release_sem(mutex->sem);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user