mirror of
https://github.com/tnodir/fort
synced 2024-11-15 07:15:39 +00:00
Driver: Improve flushing deferred packets.
This commit is contained in:
parent
1a5c45472c
commit
56b5065ffd
@ -729,6 +729,12 @@ fort_callout_force_reauth (PDEVICE_OBJECT device,
|
||||
return status;
|
||||
}
|
||||
|
||||
static void
|
||||
fort_callout_defer_flush (BOOL dispatchLevel)
|
||||
{
|
||||
fort_defer_flush(&g_device->defer, fort_transport_inject_complete, dispatchLevel);
|
||||
}
|
||||
|
||||
static void
|
||||
fort_callout_timer (void)
|
||||
{
|
||||
@ -777,17 +783,7 @@ fort_callout_timer (void)
|
||||
}
|
||||
|
||||
/* Flush deferred packets */
|
||||
fort_defer_dpc_flush(&g_device->defer, fort_transport_inject_complete);
|
||||
}
|
||||
|
||||
static void
|
||||
fort_callout_timer_force (void)
|
||||
{
|
||||
KLOCK_QUEUE_HANDLE lock_queue;
|
||||
|
||||
KeAcquireInStackQueuedSpinLock(&g_device->conf_lock, &lock_queue);
|
||||
fort_callout_timer(); /* Should be called from DISPATCH_LEVEL! */
|
||||
KeReleaseInStackQueuedSpinLock(&lock_queue);
|
||||
fort_callout_defer_flush(TRUE);
|
||||
}
|
||||
|
||||
static NTSTATUS
|
||||
@ -958,7 +954,7 @@ fort_power_callback (PVOID context, PVOID event, PVOID specifics)
|
||||
g_device->power_off = power_off;
|
||||
|
||||
if (power_off) {
|
||||
fort_callout_timer_force();
|
||||
fort_callout_defer_flush(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1002,7 +998,7 @@ fort_driver_unload (PDRIVER_OBJECT driver)
|
||||
UNICODE_STRING device_link;
|
||||
|
||||
if (g_device != NULL) {
|
||||
fort_callout_timer_force();
|
||||
fort_callout_defer_flush(FALSE);
|
||||
|
||||
fort_timer_close(&g_device->timer);
|
||||
fort_defer_close(&g_device->defer);
|
||||
|
@ -325,19 +325,29 @@ fort_defer_inject_out (PFORT_DEFER defer, PFORT_PACKET pkt,
|
||||
}
|
||||
|
||||
static void
|
||||
fort_defer_dpc_flush (PFORT_DEFER defer, FORT_INJECT_COMPLETE_FUNC complete_func)
|
||||
fort_defer_flush (PFORT_DEFER defer,
|
||||
FORT_INJECT_COMPLETE_FUNC complete_func,
|
||||
BOOL dispatchLevel)
|
||||
{
|
||||
KLOCK_QUEUE_HANDLE lock_queue;
|
||||
PFORT_PACKET pkt;
|
||||
|
||||
KeAcquireInStackQueuedSpinLockAtDpcLevel(&defer->lock, &lock_queue);
|
||||
if (dispatchLevel) {
|
||||
KeAcquireInStackQueuedSpinLockAtDpcLevel(&defer->lock, &lock_queue);
|
||||
} else {
|
||||
KeAcquireInStackQueuedSpinLock(&defer->lock, &lock_queue);
|
||||
}
|
||||
|
||||
pkt = defer->packet_head;
|
||||
if (pkt != NULL) {
|
||||
defer->packet_head = defer->packet_tail = NULL;
|
||||
}
|
||||
|
||||
KeReleaseInStackQueuedSpinLockFromDpcLevel(&lock_queue);
|
||||
if (dispatchLevel) {
|
||||
KeReleaseInStackQueuedSpinLockFromDpcLevel(&lock_queue);
|
||||
} else {
|
||||
KeReleaseInStackQueuedSpinLock(&lock_queue);
|
||||
}
|
||||
|
||||
while (pkt != NULL) {
|
||||
PFORT_PACKET pkt_next = pkt->next;
|
||||
|
Loading…
Reference in New Issue
Block a user