VOID KeReleaseDispatcherDatabaseLockAtDpcLevel(BOOLEAN Wait)
{
- DPRINT("KeReleaseDispatcherDatabaseLockAtDpcLevel(Wait %x)\n", Wait);
- assert(Wait == WaitSet);
- if (!Wait)
+ DPRINT("KeReleaseDispatcherDatabaseLockAtDpcLevel(Wait %x) WaitSet=%x\n", Wait, WaitSet);
+ if (Wait == WaitSet)
{
Owner = NULL;
KeReleaseSpinLockFromDpcLevel(&DispatcherDatabaseLock);
VOID KeReleaseDispatcherDatabaseLock(BOOLEAN Wait)
{
- DPRINT("KeReleaseDispatcherDatabaseLock(Wait %x)\n",Wait);
- assert(Wait==WaitSet);
- if (!Wait)
+ DPRINT("KeReleaseDispatcherDatabaseLock(Wait %x) WaitSet=%x\n",Wait,WaitSet);
+ if (Wait == WaitSet)
{
Owner = NULL;
KeReleaseSpinLock(&DispatcherDatabaseLock, oldlvl);
if (Thread == NULL)
{
DPRINT("Thread == NULL!\n");
- KeBugCheck(0);
+ KEBUGCHECK(0);
}
Abandoned = Mutex->Abandoned;
if (Thread != NULL)
default:
DbgPrint("(%s:%d) Dispatcher object %x has unknown type\n", __FILE__, __LINE__, hdr);
- KeBugCheck(0);
+ KEBUGCHECK(0);
}
return Abandoned;
}
}
-VOID KeRemoveAllWaitsThread(PETHREAD Thread, NTSTATUS WaitStatus)
+VOID KeRemoveAllWaitsThread(PETHREAD Thread, NTSTATUS WaitStatus, BOOL Unblock)
{
- PKWAIT_BLOCK WaitBlock;
+ PKWAIT_BLOCK WaitBlock, PrevWaitBlock;
BOOLEAN WasWaiting = FALSE;
KeAcquireDispatcherDatabaseLock(FALSE);
}
while (WaitBlock != NULL)
{
- RemoveEntryList(&WaitBlock->WaitListEntry);
+ if (WaitBlock->WaitListEntry.Flink != NULL && WaitBlock->WaitListEntry.Blink != NULL)
+ {
+ RemoveEntryList (&WaitBlock->WaitListEntry);
+ WaitBlock->WaitListEntry.Flink = WaitBlock->WaitListEntry.Blink = NULL;
+ }
+ PrevWaitBlock = WaitBlock;
WaitBlock = WaitBlock->NextWaitBlock;
+ PrevWaitBlock->NextWaitBlock = NULL;
}
Thread->Tcb.WaitBlockList = NULL;
- if (WasWaiting)
+ if (WasWaiting && Unblock)
{
PsUnblockThread(Thread, &WaitStatus);
}
WaiterHead = CONTAINING_RECORD(EnumEntry, KWAIT_BLOCK, WaitListEntry);
DPRINT("current_entry %x current %x\n", EnumEntry, WaiterHead);
EnumEntry = EnumEntry->Flink;
+ assert(WaiterHead->Thread != NULL);
assert(WaiterHead->Thread->WaitBlockList != NULL);
Abandoned = FALSE;
DPRINT("WaitAny: Remove all wait blocks.\n");
for (Waiter = WaiterHead->Thread->WaitBlockList; Waiter; Waiter = Waiter->NextWaitBlock)
{
- RemoveEntryList(&Waiter->WaitListEntry);
+ if (Waiter->WaitListEntry.Flink != NULL && Waiter->WaitListEntry.Blink != NULL)
+ {
+ RemoveEntryList(&Waiter->WaitListEntry);
+ Waiter->WaitListEntry.Flink = Waiter->WaitListEntry.Blink = NULL;
+ }
}
WaiterHead->Thread->WaitBlockList = NULL;
{
for (Waiter = WaiterHead->Thread->WaitBlockList; Waiter; Waiter = Waiter->NextWaitBlock)
{
- RemoveEntryList(&Waiter->WaitListEntry);
-
+ if (Waiter->WaitListEntry.Flink != NULL && Waiter->WaitListEntry.Blink != NULL)
+ {
+ RemoveEntryList(&Waiter->WaitListEntry);
+ Waiter->WaitListEntry.Flink = Waiter->WaitListEntry.Blink = NULL;
+ }
+
if (Waiter->WaitType == WaitAll)
{
Abandoned = KiSideEffectsBeforeWake(Waiter->Object, Waiter->Thread)
return(KeDispatcherObjectWakeOne(hdr));
}
DbgPrint("Dispatcher object %x has unknown type %d\n", hdr, hdr->Type);
- KeBugCheck(0);
+ KEBUGCHECK(0);
return(FALSE);
}
+/*
+ * @implemented
+ */
NTSTATUS STDCALL
KeWaitForSingleObject(PVOID Object,
KWAIT_REASON WaitReason,
}
+/*
+ * @implemented
+ */
NTSTATUS STDCALL
KeWaitForMultipleObjects(ULONG Count,
PVOID Object[],
{
KeAcquireDispatcherDatabaseLock(FALSE);
- /*
+ /*
* If we are going to wait alertably and a user apc is pending
* then return
*/
//io completion
if (CurrentThread->Queue)
{
- CurrentThread->Queue->RunningThreads--;
- if (WaitReason != WrQueue && CurrentThread->Queue->RunningThreads < CurrentThread->Queue->MaximumThreads &&
+ CurrentThread->Queue->CurrentCount--;
+ if (WaitReason != WrQueue && CurrentThread->Queue->CurrentCount < CurrentThread->Queue->MaximumCount &&
!IsListEmpty(&CurrentThread->Queue->EntryListHead))
{
KeDispatcherObjectWake(&CurrentThread->Queue->Header);
//io completion
if (CurrentThread->Queue)
{
- CurrentThread->Queue->RunningThreads++;
+ CurrentThread->Queue->CurrentCount++;
}
}
+/*
+ * @implemented
+ */
NTSTATUS STDCALL
NtWaitForSingleObject(IN HANDLE Object,
IN BOOLEAN Alertable,