Author: arty
Date: Tue Jul 22 07:53:25 2008
New Revision: 34682
URL:
http://svn.reactos.org/svn/reactos?rev=34682&view=rev
Log:
Patch by Cameron Gutman (aicommander <at> gmail <dot> com)
- Fix a few issues in the cancel routine
- Don't wait on an event we haven't set
- Don't mark the IRP pending when in DispPrepareIrpForCancel
Modified:
trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c
trunk/reactos/drivers/network/tcpip/tcpip/irp.c
trunk/reactos/drivers/network/tcpip/tcpip/main.c
Modified: trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/tcpi…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c [iso-8859-1] Tue Jul 22 07:53:25
2008
@@ -33,7 +33,6 @@
IoAcquireCancelSpinLock(&OldIrql);
if (!Irp->Cancel) {
- IoMarkIrpPending(Irp);
(void)IoSetCancelRoutine(Irp, CancelRoutine);
IoReleaseCancelSpinLock(OldIrql);
@@ -187,7 +186,8 @@
TI_DbgPrint(DEBUG_IRP, ("IRP at (0x%X) MinorFunction (0x%X) IrpSp
(0x%X).\n", Irp, MinorFunction, IrpSp));
- Irp->IoStatus.Status = STATUS_PENDING;
+ Irp->IoStatus.Status = STATUS_CANCELLED;
+ Irp->IoStatus.Information = 0;
#ifdef DBG
if (!Irp->Cancel)
@@ -212,7 +212,6 @@
break;
case TDI_SEND_DATAGRAM:
- Irp->IoStatus.Status = STATUS_CANCELLED;
if (FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE) {
TI_DbgPrint(MIN_TRACE, ("TDI_SEND_DATAGRAM, but no address
file.\n"));
break;
@@ -222,7 +221,6 @@
break;
case TDI_RECEIVE_DATAGRAM:
- Irp->IoStatus.Status = STATUS_CANCELLED;
if (FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE) {
TI_DbgPrint(MIN_TRACE, ("TDI_RECEIVE_DATAGRAM, but no address
file.\n"));
break;
@@ -235,9 +233,6 @@
TI_DbgPrint(MIN_TRACE, ("Unknown IRP. MinorFunction (0x%X).\n",
MinorFunction));
break;
}
-
- if( Irp->IoStatus.Status == STATUS_PENDING )
- IoMarkIrpPending(Irp);
IoReleaseCancelSpinLock(Irp->CancelIrql);
@@ -1453,7 +1448,6 @@
PTCP_REQUEST_SET_INFORMATION_EX Info;
TDI_REQUEST Request;
TDI_STATUS Status;
- KIRQL OldIrql;
TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
@@ -1489,12 +1483,6 @@
Status = InfoTdiSetInformationEx(&Request, &Info->ID,
&Info->Buffer, Info->BufferSize);
-
- if (Status != STATUS_PENDING) {
- IoAcquireCancelSpinLock(&OldIrql);
- (void)IoSetCancelRoutine(Irp, NULL);
- IoReleaseCancelSpinLock(OldIrql);
- }
}
return Status;
Modified: trunk/reactos/drivers/network/tcpip/tcpip/irp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/tcpi…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/tcpip/irp.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/tcpip/irp.c [iso-8859-1] Tue Jul 22 07:53:25 2008
@@ -18,6 +18,9 @@
}
NTSTATUS IRPFinish( PIRP Irp, NTSTATUS Status ) {
+ KIRQL Irql;
+ PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
+
//DbgPrint("Called: Irp %x, Status %x Event %x\n", Irp, Status,
Irp->UserEvent);
#ifdef MEMTRACK
@@ -30,7 +33,14 @@
IoMarkIrpPending( Irp );
else {
Irp->IoStatus.Status = Status;
+ Irql = KeGetCurrentIrql();
+
IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
+ if (KeGetCurrentIrql() != Irql) {
+ DbgPrint("WARNING: IO COMPLETION RETURNED AT WRONG IRQL:\n");
+ DbgPrint("WARNING: IRP TYPE WAS %d\n", IrpSp->MajorFunction);
+ }
+ ASSERT(KeGetCurrentIrql() == Irql);
}
return Status;
Modified: trunk/reactos/drivers/network/tcpip/tcpip/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/tcpi…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/tcpip/main.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/tcpip/main.c [iso-8859-1] Tue Jul 22 07:53:25
2008
@@ -345,14 +345,22 @@
Context->CancelIrps = FALSE;
IoReleaseCancelSpinLock(OldIrql);
- return STATUS_INVALID_PARAMETER;
+ Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
+
+ return Irp->IoStatus.Status;
}
if (Status != STATUS_PENDING)
- TiCleanupFileObjectComplete(Irp, Status);
-
- KeWaitForSingleObject(&Context->CleanupEvent,
- UserRequest, KernelMode, FALSE, NULL);
+ {
+ IoAcquireCancelSpinLock(&OldIrql);
+ KeSetEvent(&Context->CleanupEvent, 0, FALSE);
+ IoReleaseCancelSpinLock(OldIrql);
+
+ KeWaitForSingleObject(&Context->CleanupEvent,
+ UserRequest, KernelMode, FALSE, NULL);
+ }
+
+ Irp->IoStatus.Status = Status;
return Irp->IoStatus.Status;
}