The SemaphorePool method could hand out unbalanced semaphores - it only called
Semaphore::ZeroCount() on new semaphores, not on used ones. Found by Stefano, thanks! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20052 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2005, Ingo Weinhold, [email protected].
|
* Copyright 2005-2007, Ingo Weinhold, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -75,12 +75,6 @@ SemaphorePool::Get(Semaphore *&semaphore)
|
|||||||
if (!sem)
|
if (!sem)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
status_t error = sem->ZeroCount();
|
|
||||||
if (error != B_OK) {
|
|
||||||
delete sem;
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
semaphore = sem;
|
semaphore = sem;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -94,7 +88,9 @@ SemaphorePool::Put(Semaphore *semaphore)
|
|||||||
|
|
||||||
MutexLocker _(fLock);
|
MutexLocker _(fLock);
|
||||||
|
|
||||||
if (fCount >= fMaxCount || semaphore->InitCheck() != B_OK) {
|
if (fCount >= fMaxCount
|
||||||
|
|| semaphore->InitCheck() != B_OK
|
||||||
|
|| semaphore->ZeroCount() != B_OK) {
|
||||||
delete semaphore;
|
delete semaphore;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user