From 7c78a4281675509064a3f2fc66a940517988450e Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 10 Aug 2009 21:21:50 +0000 Subject: [PATCH] - Make Connect IRPs cancellable (should fix some deadlock issues) - Fix a bug which could result in a Listen IRP being unable to be cancelled svn path=/trunk/; revision=42604 --- .../drivers/network/tcpip/tcpip/dispatch.c | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/reactos/drivers/network/tcpip/tcpip/dispatch.c b/reactos/drivers/network/tcpip/tcpip/dispatch.c index d7402749833..0b4e2f5dd30 100644 --- a/reactos/drivers/network/tcpip/tcpip/dispatch.c +++ b/reactos/drivers/network/tcpip/tcpip/dispatch.c @@ -192,6 +192,10 @@ VOID NTAPI DispCancelRequest( 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 @@ NTSTATUS DispTdiConnect( 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 @@ NTSTATUS DispTdiListen( 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 ); @@ -603,12 +618,6 @@ NTSTATUS DispTdiListen( Status = TCPListen( Connection->AddressFile->Listener, 1024 ); /* BACKLOG */ } - if( NT_SUCCESS(Status) ) { - Status = DispPrepareIrpForCancel - (TranContext->Handle.ConnectionContext, - Irp, - (PDRIVER_CANCEL)DispCancelListenRequest); - } if( NT_SUCCESS(Status) ) { Status = TCPAccept