Author: cgutman
Date: Mon Oct 5 03:44:17 2009
New Revision: 43296
URL:
http://svn.reactos.org/svn/reactos?rev=43296&view=rev
Log:
- Cancel pending user IRPs when we get a IRP_MJ_CLEANUP request
- Previously there was some confusion between IRPs in PendingIrpList and InFlightRequest,
InFlightRequest IRPs go from AFD to a TDI transport driver (tcpip) which are sent on
behalf of AFD and are cancelled upon socket destruction (IRP_MJ_CLOSE) vs. IRPs in the
PendingIrpList which go from user-mode to AFD which are sent of behalf of the user and
should be cancelled when handling IRP_MJ_CLEANUP
Modified:
trunk/reactos/drivers/network/afd/afd/main.c
Modified: trunk/reactos/drivers/network/afd/afd/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/ma…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/main.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/main.c [iso-8859-1] Mon Oct 5 03:44:17 2009
@@ -172,6 +172,38 @@
}
static NTSTATUS NTAPI
+AfdCleanupSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
+ PIO_STACK_LOCATION IrpSp)
+{
+ PFILE_OBJECT FileObject = IrpSp->FileObject;
+ PAFD_FCB FCB = FileObject->FsContext;
+ PLIST_ENTRY CurrentEntry, NextEntry;
+ UINT Function;
+ PIRP CurrentIrp;
+
+ if( !SocketAcquireStateLock( FCB ) ) return LostSocket(Irp);
+
+ for (Function = 0; Function < MAX_FUNCTIONS; Function++)
+ {
+ CurrentEntry = FCB->PendingIrpList[Function].Flink;
+ while (CurrentEntry != &FCB->PendingIrpList[Function])
+ {
+ NextEntry = CurrentEntry->Flink;
+ CurrentIrp = CONTAINING_RECORD(CurrentEntry, IRP, Tail.Overlay.ListEntry);
+
+ /* The cancel routine will remove the IRP from the list */
+ IoCancelIrp(CurrentIrp);
+
+ CurrentEntry = NextEntry;
+ }
+ }
+
+ KillSelectsForFCB( FCB->DeviceExt, FileObject, FALSE );
+
+ return UnlockAndMaybeComplete(FCB, STATUS_SUCCESS, Irp, 0);
+}
+
+static NTSTATUS NTAPI
AfdCloseSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
PIO_STACK_LOCATION IrpSp)
{
@@ -346,6 +378,9 @@
case IRP_MJ_CLOSE:
/* Ditto the borrowing */
return AfdCloseSocket(DeviceObject, Irp, IrpSp);
+
+ case IRP_MJ_CLEANUP:
+ return AfdCleanupSocket(DeviceObject, Irp, IrpSp);
/* write data */
case IRP_MJ_WRITE:
@@ -626,6 +661,7 @@
/* register driver routines */
DriverObject->MajorFunction[IRP_MJ_CLOSE] = AfdDispatch;
DriverObject->MajorFunction[IRP_MJ_CREATE] = AfdDispatch;
+ DriverObject->MajorFunction[IRP_MJ_CLEANUP] = AfdDispatch;
DriverObject->MajorFunction[IRP_MJ_WRITE] = AfdDispatch;
DriverObject->MajorFunction[IRP_MJ_READ] = AfdDispatch;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = AfdDispatch;