Author: cgutman
Date: Sat Oct 31 19:46:08 2009
New Revision: 43883
URL:
http://svn.reactos.org/svn/reactos?rev=43883&view=rev
Log:
- Don't disconnect the same socket multiple times (once per TDI_SEND IRP cancelled,
once per TDI_RECEIVE IRP cancelled, once per TDI_SEND IRP on a closing socket, and once
per TDI_RECEIVE IRP on a closing socket)
- Implement support for graceful socket closure
- Fix some memory leaks
Modified:
trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c
trunk/reactos/lib/drivers/ip/transport/tcp/tcp.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] Sat Oct 31 19:46:08
2009
@@ -102,26 +102,6 @@
TI_DbgPrint(DEBUG_IRP, ("Done Completing IRP\n"));
}
-VOID DispDoDisconnect( PVOID Data ) {
- PDISCONNECT_TYPE DisType = (PDISCONNECT_TYPE)Data;
-
- TI_DbgPrint(DEBUG_IRP, ("PostCancel: DoDisconnect\n"));
- TcpipRecursiveMutexEnter(&TCPLock, TRUE);
- TCPDisconnect
- ( DisType->Context,
- DisType->Type,
- NULL,
- NULL,
- DispDataRequestComplete,
- DisType->Irp );
- TcpipRecursiveMutexLeave(&TCPLock);
- TI_DbgPrint(DEBUG_IRP, ("PostCancel: DoDisconnect done\n"));
-
- DispDataRequestComplete(DisType->Irp, STATUS_CANCELLED, 0);
-
- exFreePool(DisType);
-}
-
VOID NTAPI DispCancelRequest(
PDEVICE_OBJECT Device,
PIRP Irp)
@@ -136,7 +116,6 @@
PTRANSPORT_CONTEXT TranContext;
PFILE_OBJECT FileObject;
UCHAR MinorFunction;
- PDISCONNECT_TYPE DisType;
TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
@@ -159,22 +138,8 @@
switch(MinorFunction) {
case TDI_SEND:
case TDI_RECEIVE:
- DisType = exAllocatePool(NonPagedPool, sizeof(DISCONNECT_TYPE));
- if (DisType)
- {
- DisType->Type = TDI_DISCONNECT_RELEASE |
- ((MinorFunction == TDI_RECEIVE) ? TDI_DISCONNECT_ABORT : 0);
- DisType->Context = TranContext->Handle.ConnectionContext;
- DisType->Irp = Irp;
-
- TCPRemoveIRP( TranContext->Handle.ConnectionContext, Irp );
-
- if (!ChewCreate(DispDoDisconnect, DisType))
- exFreePool(DisType);
- }
-
- IoReleaseCancelSpinLock(Irp->CancelIrql);
- return;
+ TCPRemoveIRP( TranContext->Handle.ConnectionContext, Irp );
+ break;
case TDI_SEND_DATAGRAM:
if (FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE) {
Modified: trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/t…
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] Sat Oct 31 19:46:08
2009
@@ -44,15 +44,6 @@
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
Complete = Bucket->Request.RequestNotifyObject;
- /* We have to notify oskittcp of the abortion */
- TCPDisconnect
- ( Connection,
- TDI_DISCONNECT_RELEASE | TDI_DISCONNECT_ABORT,
- NULL,
- NULL,
- Bucket->Request.RequestNotifyObject,
- (PIRP)Bucket->Request.RequestContext );
-
Complete( Bucket->Request.RequestContext, STATUS_CANCELLED, 0 );
exFreePool(Bucket);
@@ -64,15 +55,6 @@
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
Complete = Bucket->Request.RequestNotifyObject;
- /* We have to notify oskittcp of the abortion */
- TCPDisconnect
- ( Connection,
- TDI_DISCONNECT_RELEASE,
- NULL,
- NULL,
- Bucket->Request.RequestNotifyObject,
- (PIRP)Bucket->Request.RequestContext );
-
Complete( Bucket->Request.RequestContext, STATUS_CANCELLED, 0 );
exFreePool(Bucket);
@@ -89,6 +71,8 @@
Connection);
Complete( Bucket->Request.RequestContext, STATUS_CANCELLED, 0 );
+
+ exFreePool(Bucket);
}
while ((Entry = ExInterlockedRemoveHeadList( &Connection->ConnectRequest,
@@ -98,6 +82,8 @@
Complete = Bucket->Request.RequestNotifyObject;
Complete( Bucket->Request.RequestContext, STATUS_CANCELLED, 0 );
+
+ exFreePool(Bucket);
}
Connection->SignalState = 0;
@@ -671,29 +657,17 @@
PTDI_CONNECTION_INFORMATION ReturnInfo,
PTCP_COMPLETION_ROUTINE Complete,
PVOID Context ) {
- NTSTATUS Status;
+ NTSTATUS Status = STATUS_INVALID_PARAMETER;
ASSERT_LOCKED(&TCPLock);
TI_DbgPrint(DEBUG_TCP,("started\n"));
- switch( Flags & (TDI_DISCONNECT_ABORT | TDI_DISCONNECT_RELEASE) ) {
- case 0:
- case TDI_DISCONNECT_ABORT:
- Flags = 0;
- break;
-
- case TDI_DISCONNECT_ABORT | TDI_DISCONNECT_RELEASE:
- Flags = 2;
- break;
-
- case TDI_DISCONNECT_RELEASE:
- Flags = 1;
- break;
- }
-
- Status = TCPTranslateError
- ( OskitTCPShutdown( Connection->SocketContext, Flags ) );
+ if (Flags & TDI_DISCONNECT_RELEASE)
+ Status = TCPTranslateError(OskitTCPDisconnect(Connection->SocketContext));
+
+ if ((Flags & TDI_DISCONNECT_ABORT) || !Flags)
+ Status = TCPTranslateError(OskitTCPShutdown(Connection->SocketContext, FWRITE
| FREAD));
TI_DbgPrint(DEBUG_TCP,("finished %x\n", Status));