mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 07:22:58 +00:00
- Fix (and optimize) KeRemoveByKeyDeviceQueue() routine.
- Add DPRINTs for easier testing/debugging. svn path=/trunk/; revision=26165
This commit is contained in:
parent
34713168d4
commit
51147f6c84
1 changed files with 46 additions and 16 deletions
|
@ -45,6 +45,8 @@ KeInsertDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue,
|
||||||
BOOLEAN Inserted;
|
BOOLEAN Inserted;
|
||||||
ASSERT_DEVICE_QUEUE(DeviceQueue);
|
ASSERT_DEVICE_QUEUE(DeviceQueue);
|
||||||
|
|
||||||
|
DPRINT("KeInsertDeviceQueue() DevQueue %p, Entry %p\n", DeviceQueue, DeviceQueueEntry);
|
||||||
|
|
||||||
/* Lock the queue */
|
/* Lock the queue */
|
||||||
KiAcquireDeviceQueueLock(DeviceQueue, &DeviceLock);
|
KiAcquireDeviceQueueLock(DeviceQueue, &DeviceLock);
|
||||||
|
|
||||||
|
@ -86,6 +88,8 @@ KeInsertByKeyDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue,
|
||||||
BOOLEAN Inserted;
|
BOOLEAN Inserted;
|
||||||
ASSERT_DEVICE_QUEUE(DeviceQueue);
|
ASSERT_DEVICE_QUEUE(DeviceQueue);
|
||||||
|
|
||||||
|
DPRINT("KeInsertByKeyDeviceQueue() DevQueue %p, Entry %p, SortKey 0x%x\n", DeviceQueue, DeviceQueueEntry, SortKey);
|
||||||
|
|
||||||
/* Lock the queue */
|
/* Lock the queue */
|
||||||
KiAcquireDeviceQueueLock(DeviceQueue, &DeviceLock);
|
KiAcquireDeviceQueueLock(DeviceQueue, &DeviceLock);
|
||||||
|
|
||||||
|
@ -129,6 +133,8 @@ KeRemoveDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue)
|
||||||
KLOCK_QUEUE_HANDLE DeviceLock;
|
KLOCK_QUEUE_HANDLE DeviceLock;
|
||||||
ASSERT_DEVICE_QUEUE(DeviceQueue);
|
ASSERT_DEVICE_QUEUE(DeviceQueue);
|
||||||
|
|
||||||
|
DPRINT("KeRemoveDeviceQueue() DevQueue %p\n", DeviceQueue);
|
||||||
|
|
||||||
/* Lock the queue */
|
/* Lock the queue */
|
||||||
KiAcquireDeviceQueueLock(DeviceQueue, &DeviceLock);
|
KiAcquireDeviceQueueLock(DeviceQueue, &DeviceLock);
|
||||||
ASSERT(DeviceQueue->Busy);
|
ASSERT(DeviceQueue->Busy);
|
||||||
|
@ -172,6 +178,8 @@ KeRemoveByKeyDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue,
|
||||||
KLOCK_QUEUE_HANDLE DeviceLock;
|
KLOCK_QUEUE_HANDLE DeviceLock;
|
||||||
ASSERT_DEVICE_QUEUE(DeviceQueue);
|
ASSERT_DEVICE_QUEUE(DeviceQueue);
|
||||||
|
|
||||||
|
DPRINT("KeRemoveByKeyDeviceQueue() DevQueue %p, SortKey 0x%x\n", DeviceQueue, SortKey);
|
||||||
|
|
||||||
/* Lock the queue */
|
/* Lock the queue */
|
||||||
KiAcquireDeviceQueueLock(DeviceQueue, &DeviceLock);
|
KiAcquireDeviceQueueLock(DeviceQueue, &DeviceLock);
|
||||||
ASSERT(DeviceQueue->Busy);
|
ASSERT(DeviceQueue->Busy);
|
||||||
|
@ -185,26 +193,44 @@ KeRemoveByKeyDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Find entry with SortKey greater than or equal to the passed-in SortKey */
|
/* If SortKey is greater than the last key, then return the first entry right away */
|
||||||
LIST_FOR_EACH(ReturnEntry, &DeviceQueue->DeviceListHead, KDEVICE_QUEUE_ENTRY, DeviceListEntry)
|
ListEntry = &DeviceQueue->DeviceListHead;
|
||||||
{
|
ReturnEntry = CONTAINING_RECORD(ListEntry->Blink,
|
||||||
/* Check if keys match */
|
KDEVICE_QUEUE_ENTRY,
|
||||||
if (ReturnEntry->SortKey >= SortKey)
|
DeviceListEntry);
|
||||||
{
|
|
||||||
/* We found it, so just remove it */
|
|
||||||
RemoveEntryList(&ReturnEntry->DeviceListEntry);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if we found something */
|
if (SortKey >= ReturnEntry->SortKey)
|
||||||
if (!ReturnEntry)
|
|
||||||
{
|
{
|
||||||
/* Not found, return the first entry */
|
ReturnEntry = CONTAINING_RECORD(ListEntry->Flink,
|
||||||
ListEntry = RemoveHeadList(&DeviceQueue->DeviceListHead);
|
|
||||||
ReturnEntry = CONTAINING_RECORD(ListEntry,
|
|
||||||
KDEVICE_QUEUE_ENTRY,
|
KDEVICE_QUEUE_ENTRY,
|
||||||
DeviceListEntry);
|
DeviceListEntry);
|
||||||
|
|
||||||
|
/* Remove it from the list */
|
||||||
|
RemoveEntryList(&ReturnEntry->DeviceListEntry);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Find entry with SortKey greater than or equal to the passed-in SortKey */
|
||||||
|
LIST_FOR_EACH(ReturnEntry, &DeviceQueue->DeviceListHead, KDEVICE_QUEUE_ENTRY, DeviceListEntry)
|
||||||
|
{
|
||||||
|
/* Check if keys match */
|
||||||
|
if (ReturnEntry->SortKey >= SortKey)
|
||||||
|
{
|
||||||
|
/* We found it, so just remove it */
|
||||||
|
RemoveEntryList(&ReturnEntry->DeviceListEntry);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if we found something */
|
||||||
|
if (!ReturnEntry)
|
||||||
|
{
|
||||||
|
/* Not found, return the first entry */
|
||||||
|
ListEntry = RemoveHeadList(&DeviceQueue->DeviceListHead);
|
||||||
|
ReturnEntry = CONTAINING_RECORD(ListEntry,
|
||||||
|
KDEVICE_QUEUE_ENTRY,
|
||||||
|
DeviceListEntry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set it as non-inserted */
|
/* Set it as non-inserted */
|
||||||
|
@ -231,6 +257,8 @@ KeRemoveByKeyDeviceQueueIfBusy(IN PKDEVICE_QUEUE DeviceQueue,
|
||||||
KLOCK_QUEUE_HANDLE DeviceLock;
|
KLOCK_QUEUE_HANDLE DeviceLock;
|
||||||
ASSERT_DEVICE_QUEUE(DeviceQueue);
|
ASSERT_DEVICE_QUEUE(DeviceQueue);
|
||||||
|
|
||||||
|
DPRINT("KeRemoveByKeyDeviceQueueIfBusy() DevQueue %p, SortKey 0x%x\n", DeviceQueue, SortKey);
|
||||||
|
|
||||||
/* Lock the queue */
|
/* Lock the queue */
|
||||||
KiAcquireDeviceQueueLock(DeviceQueue, &DeviceLock);
|
KiAcquireDeviceQueueLock(DeviceQueue, &DeviceLock);
|
||||||
|
|
||||||
|
@ -288,6 +316,8 @@ KeRemoveEntryDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue,
|
||||||
KLOCK_QUEUE_HANDLE DeviceLock;
|
KLOCK_QUEUE_HANDLE DeviceLock;
|
||||||
ASSERT_DEVICE_QUEUE(DeviceQueue);
|
ASSERT_DEVICE_QUEUE(DeviceQueue);
|
||||||
|
|
||||||
|
DPRINT("KeRemoveEntryDeviceQueue() DevQueue %p, Entry %p\n", DeviceQueue, DeviceQueueEntry);
|
||||||
|
|
||||||
/* Lock the queue */
|
/* Lock the queue */
|
||||||
KiAcquireDeviceQueueLock(DeviceQueue, &DeviceLock);
|
KiAcquireDeviceQueueLock(DeviceQueue, &DeviceLock);
|
||||||
ASSERT(DeviceQueue->Busy);
|
ASSERT(DeviceQueue->Busy);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue