[ros-diffs] [cgutman] 42604: - Make Connect IRPs cancellable (should fix some deadlock issues) - Fix a bug which could result in a Listen IRP being unable to be cancelled

cgutman at svn.reactos.org cgutman at svn.reactos.org
Mon Aug 10 23:21:51 CEST 2009


Author: cgutman
Date: Mon Aug 10 23:21:50 2009
New Revision: 42604

URL: http://svn.reactos.org/svn/reactos?rev=42604&view=rev
Log:
 - Make Connect IRPs cancellable (should fix some deadlock issues)
 - Fix a bug which could result in a Listen IRP being unable to be cancelled

Modified:
    trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c

Modified: trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c?rev=42604&r1=42603&r2=42604&view=diff
==============================================================================
--- trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c [iso-8859-1] Mon Aug 10 23:21:50 2009
@@ -192,6 +192,10 @@
         DGRemoveIRP(TranContext->Handle.AddressHandle, Irp);
         break;
 
+    case TDI_CONNECT:
+        TCPRemoveIRP(TranContext->Handle.ConnectionContext, Irp);
+        break;
+
     default:
         TI_DbgPrint(MIN_TRACE, ("Unknown IRP. MinorFunction (0x%X).\n", MinorFunction));
         break;
@@ -399,12 +403,18 @@
 
   Parameters = (PTDI_REQUEST_KERNEL)&IrpSp->Parameters;
 
-  Status = TCPConnect(
-      TranContext->Handle.ConnectionContext,
-      Parameters->RequestConnectionInformation,
-      Parameters->ReturnConnectionInformation,
-      DispDataRequestComplete,
-      Irp );
+  Status = DispPrepareIrpForCancel(TranContext->Handle.ConnectionContext,
+                                   Irp,
+                                   DispCancelRequest);
+
+  if (NT_SUCCESS(Status)) {
+      Status = TCPConnect(
+          TranContext->Handle.ConnectionContext,
+          Parameters->RequestConnectionInformation,
+          Parameters->ReturnConnectionInformation,
+          DispDataRequestComplete,
+          Irp );
+  }
 
 done:
   TcpipRecursiveMutexLeave( &TCPLock );
@@ -577,12 +587,17 @@
 			      Connection->AddressFile->Listener));
   }
 
+  Status = DispPrepareIrpForCancel
+      (TranContext->Handle.ConnectionContext,
+       Irp,
+       (PDRIVER_CANCEL)DispCancelListenRequest);
+
   /* Listening will require us to create a listening socket and store it in
    * the address file.  It will be signalled, and attempt to complete an irp
    * when a new connection arrives. */
   /* The important thing to note here is that the irp we'll complete belongs
    * to the socket to be accepted onto, not the listener */
-  if( !Connection->AddressFile->Listener ) {
+  if( NT_SUCCESS(Status) && !Connection->AddressFile->Listener ) {
       Connection->AddressFile->Listener =
 	  TCPAllocateConnectionEndpoint( NULL );
 
@@ -602,12 +617,6 @@
       if( NT_SUCCESS(Status) )
 	  Status = TCPListen( Connection->AddressFile->Listener, 1024 );
 	  /* BACKLOG */
-  }
-  if( NT_SUCCESS(Status) ) {
-      Status = DispPrepareIrpForCancel
-          (TranContext->Handle.ConnectionContext,
-           Irp,
-           (PDRIVER_CANCEL)DispCancelListenRequest);
   }
 
   if( NT_SUCCESS(Status) ) {




More information about the Ros-diffs mailing list