mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
correct bug in release of semaphore
svn path=/trunk/; revision=356
This commit is contained in:
parent
3763d9c0dd
commit
d7acbe2251
1 changed files with 13 additions and 21 deletions
|
@ -38,25 +38,17 @@ LONG KeReleaseSemaphore(PKSEMAPHORE Semaphore,
|
||||||
BOOLEAN Wait)
|
BOOLEAN Wait)
|
||||||
{
|
{
|
||||||
ULONG initState = Semaphore->Header.SignalState;
|
ULONG initState = Semaphore->Header.SignalState;
|
||||||
|
|
||||||
KeAcquireDispatcherDatabaseLock(Wait);
|
KeAcquireDispatcherDatabaseLock(Wait);
|
||||||
|
|
||||||
if(Semaphore->Limit < initState+Adjustment
|
if(Semaphore->Limit < initState+Adjustment
|
||||||
|| initState > initState+Adjustment)
|
|| initState > initState+Adjustment)
|
||||||
{
|
|
||||||
ExRaiseStatus(STATUS_SEMAPHORE_LIMIT_EXCEEDED);
|
ExRaiseStatus(STATUS_SEMAPHORE_LIMIT_EXCEEDED);
|
||||||
}
|
|
||||||
|
|
||||||
Semaphore->Header.SignalState+=Adjustment;
|
Semaphore->Header.SignalState+=Adjustment;
|
||||||
if(initState == 0)
|
if(initState == 0)
|
||||||
{
|
{
|
||||||
// wake up SignalState waiters
|
// wake up SignalState waiters
|
||||||
while(Semaphore->Header.SignalState > 0
|
KeDispatcherObjectWake(&Semaphore->Header) ;
|
||||||
&& KeDispatcherObjectWake(&Semaphore->Header)) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KeReleaseDispatcherDatabaseLock(Wait);
|
KeReleaseDispatcherDatabaseLock(Wait);
|
||||||
|
|
||||||
return initState;
|
return initState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue