mirror of
https://github.com/reactos/reactos.git
synced 2024-12-31 19:42:51 +00:00
Fixed [Ke/Nt]WaitForMultipleObjects() bug
svn path=/trunk/; revision=1239
This commit is contained in:
parent
db1ccdf290
commit
3ca24a2c2a
1 changed files with 60 additions and 60 deletions
|
@ -496,77 +496,77 @@ KeWaitForMultipleObjects (
|
||||||
}
|
}
|
||||||
blk = WaitBlockArray;
|
blk = WaitBlockArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeAcquireDispatcherDatabaseLock(FALSE);
|
|
||||||
|
|
||||||
for (i = 0; i < Count; i++)
|
|
||||||
{
|
|
||||||
hdr = (DISPATCHER_HEADER *)Object[i];
|
|
||||||
|
|
||||||
DPRINT("hdr->SignalState %d\n", hdr->SignalState);
|
|
||||||
|
|
||||||
if (KiIsObjectSignalled(hdr, CurrentThread))
|
|
||||||
{
|
|
||||||
CountSignaled++;
|
|
||||||
|
|
||||||
if (WaitType == WaitAny)
|
|
||||||
{
|
|
||||||
KeReleaseDispatcherDatabaseLock(FALSE);
|
|
||||||
DPRINT("One object is already signaled!\n");
|
|
||||||
return(STATUS_WAIT_0 + i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((WaitType == WaitAll) && (CountSignaled == Count))
|
|
||||||
{
|
|
||||||
KeReleaseDispatcherDatabaseLock(FALSE);
|
|
||||||
DPRINT("All objects are already signaled!\n");
|
|
||||||
return(STATUS_WAIT_0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Timeout != NULL)
|
if (Timeout != NULL)
|
||||||
{
|
{
|
||||||
KeAddThreadTimeout(CurrentThread,Timeout);
|
KeAddThreadTimeout(CurrentThread,Timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Append wait block to the KTHREAD wait block list */
|
do {
|
||||||
CurrentThread->WaitBlockList = blk;
|
KeAcquireDispatcherDatabaseLock(FALSE);
|
||||||
|
|
||||||
for (i = 0; i < Count; i++)
|
for (i = 0; i < Count; i++)
|
||||||
{
|
{
|
||||||
hdr = (DISPATCHER_HEADER *)Object[i];
|
hdr = (DISPATCHER_HEADER *)Object[i];
|
||||||
|
|
||||||
DPRINT("hdr->SignalState %d\n", hdr->SignalState);
|
DPRINT("hdr->SignalState %d\n", hdr->SignalState);
|
||||||
|
|
||||||
blk->Object = Object[i];
|
if (KiIsObjectSignalled(hdr, CurrentThread))
|
||||||
blk->Thread = CurrentThread;
|
{
|
||||||
blk->WaitKey = i;
|
CountSignaled++;
|
||||||
blk->WaitType = WaitType;
|
|
||||||
if (i == Count - 1)
|
if (WaitType == WaitAny)
|
||||||
|
{
|
||||||
|
KeReleaseDispatcherDatabaseLock(FALSE);
|
||||||
|
DPRINT("One object is already signaled!\n");
|
||||||
|
return(STATUS_WAIT_0 + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((WaitType == WaitAll) && (CountSignaled == Count))
|
||||||
|
{
|
||||||
|
KeReleaseDispatcherDatabaseLock(FALSE);
|
||||||
|
DPRINT("All objects are already signaled!\n");
|
||||||
|
return(STATUS_WAIT_0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Append wait block to the KTHREAD wait block list */
|
||||||
|
CurrentThread->WaitBlockList = blk;
|
||||||
|
|
||||||
|
for (i = 0; i < Count; i++)
|
||||||
|
{
|
||||||
|
hdr = (DISPATCHER_HEADER *)Object[i];
|
||||||
|
|
||||||
|
DPRINT("hdr->SignalState %d\n", hdr->SignalState);
|
||||||
|
|
||||||
|
blk->Object = Object[i];
|
||||||
|
blk->Thread = CurrentThread;
|
||||||
|
blk->WaitKey = i;
|
||||||
|
blk->WaitType = WaitType;
|
||||||
|
if (i == Count - 1)
|
||||||
blk->NextWaitBlock = NULL;
|
blk->NextWaitBlock = NULL;
|
||||||
else
|
else
|
||||||
blk->NextWaitBlock = blk + 1;
|
blk->NextWaitBlock = blk + 1;
|
||||||
DPRINT("blk %p blk->NextWaitBlock %p\n",
|
DPRINT("blk %p blk->NextWaitBlock %p\n",
|
||||||
blk, blk->NextWaitBlock);
|
blk, blk->NextWaitBlock);
|
||||||
InsertTailList(&(hdr->WaitListHead),&(blk->WaitListEntry));
|
InsertTailList(&(hdr->WaitListHead),&(blk->WaitListEntry));
|
||||||
// DPRINT("hdr->WaitListHead.Flink %x hdr->WaitListHead.Blink %x\n",
|
// DPRINT("hdr->WaitListHead.Flink %x hdr->WaitListHead.Blink %x\n",
|
||||||
// hdr->WaitListHead.Flink,hdr->WaitListHead.Blink);
|
// hdr->WaitListHead.Flink,hdr->WaitListHead.Blink);
|
||||||
|
|
||||||
blk = blk->NextWaitBlock;
|
blk = blk->NextWaitBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeReleaseDispatcherDatabaseLock(FALSE);
|
KeReleaseDispatcherDatabaseLock(FALSE);
|
||||||
|
|
||||||
DPRINT("Waiting at %s:%d with irql %d\n", __FILE__, __LINE__,
|
DPRINT("Waiting at %s:%d with irql %d\n", __FILE__, __LINE__,
|
||||||
KeGetCurrentIrql());
|
KeGetCurrentIrql());
|
||||||
PsFreezeThread(PsGetCurrentThread(),
|
PsFreezeThread(PsGetCurrentThread(),
|
||||||
&Status,
|
&Status,
|
||||||
Alertable,
|
Alertable,
|
||||||
WaitMode);
|
WaitMode);
|
||||||
|
} while( Status == STATUS_KERNEL_APC );
|
||||||
if (Timeout != NULL)
|
if (Timeout != NULL)
|
||||||
KeCancelTimer(&KeGetCurrentThread()->Timer);
|
KeCancelTimer(&KeGetCurrentThread()->Timer);
|
||||||
DPRINT("Returning from KeWaitForMultipleObjects()\n");
|
DPRINT("Returning from KeWaitForMultipleObjects()\n");
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue