sys: ioq: event becomes signaled when ioq is disabled

This commit is contained in:
Bill Zissimopoulos 2015-11-24 20:21:01 -08:00
parent cac74f3b63
commit 0f0b1f2c46
2 changed files with 11 additions and 5 deletions

View File

@ -152,7 +152,7 @@ static NTSTATUS FspFsvrtTransact(
} }
/* wait for a pending IRP */ /* wait for a pending IRP */
while (0 == (PendingIrp = FspIoqNextPendingIrp(&FsvrtDeviceExtension->Ioq, 300))) while (0 == (PendingIrp = FspIoqNextPendingIrp(&FsvrtDeviceExtension->Ioq, (ULONG)-1L)))
{ {
if (!FspIoqEnabled(&FsvrtDeviceExtension->Ioq)) if (!FspIoqEnabled(&FsvrtDeviceExtension->Ioq))
return STATUS_CANCELLED; return STATUS_CANCELLED;

View File

@ -48,10 +48,11 @@
* +---------------------+ * +---------------------+
* *
* *
* Pending Queue Event Object * Event Object
* *
* Note that the Pending queue is controlled by a manual event object. * The FSP_IOQ includes a manual event object. The event object remains
* The event object remains signaled for as long as the queue is not empty. * signaled when the FSP_IOQ object is disabled or when the Pending queue
* is not empty.
*/ */
static NTSTATUS FspIoqPendingInsertIrpEx(PIO_CSQ IoCsq, PIRP Irp, PVOID InsertContext) static NTSTATUS FspIoqPendingInsertIrpEx(PIO_CSQ IoCsq, PIRP Irp, PVOID InsertContext)
@ -68,7 +69,7 @@ static NTSTATUS FspIoqPendingInsertIrpEx(PIO_CSQ IoCsq, PIRP Irp, PVOID InsertCo
static VOID FspIoqPendingRemoveIrp(PIO_CSQ IoCsq, PIRP Irp) static VOID FspIoqPendingRemoveIrp(PIO_CSQ IoCsq, PIRP Irp)
{ {
FSP_IOQ *Ioq = CONTAINING_RECORD(IoCsq, FSP_IOQ, PendingIoCsq); FSP_IOQ *Ioq = CONTAINING_RECORD(IoCsq, FSP_IOQ, PendingIoCsq);
if (RemoveEntryList(&Irp->Tail.Overlay.ListEntry)) if (RemoveEntryList(&Irp->Tail.Overlay.ListEntry) && 0 < Ioq->Enabled)
/* list is empty; future threads should go to sleep */ /* list is empty; future threads should go to sleep */
KeClearEvent(&Ioq->PendingIrpEvent); KeClearEvent(&Ioq->PendingIrpEvent);
} }
@ -76,6 +77,8 @@ static VOID FspIoqPendingRemoveIrp(PIO_CSQ IoCsq, PIRP Irp)
static PIRP FspIoqPendingPeekNextIrp(PIO_CSQ IoCsq, PIRP Irp, PVOID PeekContext) static PIRP FspIoqPendingPeekNextIrp(PIO_CSQ IoCsq, PIRP Irp, PVOID PeekContext)
{ {
FSP_IOQ *Ioq = CONTAINING_RECORD(IoCsq, FSP_IOQ, PendingIoCsq); FSP_IOQ *Ioq = CONTAINING_RECORD(IoCsq, FSP_IOQ, PendingIoCsq);
if (!PeekContext && 0 >= Ioq->Enabled)
return 0;
PLIST_ENTRY Head = &Ioq->PendingIrpList; PLIST_ENTRY Head = &Ioq->PendingIrpList;
PLIST_ENTRY Entry = 0 == Irp ? Head->Flink : Irp->Tail.Overlay.ListEntry.Flink; PLIST_ENTRY Entry = 0 == Irp ? Head->Flink : Irp->Tail.Overlay.ListEntry.Flink;
return Head != Entry ? CONTAINING_RECORD(Entry, IRP, Tail.Overlay.ListEntry) : 0; return Head != Entry ? CONTAINING_RECORD(Entry, IRP, Tail.Overlay.ListEntry) : 0;
@ -115,6 +118,8 @@ static VOID FspIoqProcessRemoveIrp(PIO_CSQ IoCsq, PIRP Irp)
static PIRP FspIoqProcessPeekNextIrp(PIO_CSQ IoCsq, PIRP Irp, PVOID PeekContext) static PIRP FspIoqProcessPeekNextIrp(PIO_CSQ IoCsq, PIRP Irp, PVOID PeekContext)
{ {
FSP_IOQ *Ioq = CONTAINING_RECORD(IoCsq, FSP_IOQ, ProcessIoCsq); FSP_IOQ *Ioq = CONTAINING_RECORD(IoCsq, FSP_IOQ, ProcessIoCsq);
if (!PeekContext && 0 >= Ioq->Enabled)
return 0;
PLIST_ENTRY Head = &Ioq->ProcessIrpList; PLIST_ENTRY Head = &Ioq->ProcessIrpList;
PLIST_ENTRY Entry = 0 == Irp ? Head->Flink : Irp->Tail.Overlay.ListEntry.Flink; PLIST_ENTRY Entry = 0 == Irp ? Head->Flink : Irp->Tail.Overlay.ListEntry.Flink;
for (; Head != Entry; Entry = Entry->Flink) for (; Head != Entry; Entry = Entry->Flink)
@ -182,6 +187,7 @@ VOID FspIoqDisable(FSP_IOQ *Ioq)
KIRQL Irql; KIRQL Irql;
KeAcquireSpinLock(&Ioq->SpinLock, &Irql); KeAcquireSpinLock(&Ioq->SpinLock, &Irql);
Ioq->Enabled = 0; Ioq->Enabled = 0;
KeSetEvent(&Ioq->PendingIrpEvent, 1, FALSE);
KeReleaseSpinLock(&Ioq->SpinLock, Irql); KeReleaseSpinLock(&Ioq->SpinLock, Irql);
} }