Author: cgutman
Date: Sat Jun 27 07:23:10 2009
New Revision: 41630
URL:
http://svn.reactos.org/svn/reactos?rev=41630&view=rev
Log:
- Don't leave the listen IRP in the queue when cancelling the listen request
- Kill all the requests before closing the socket
- Notify oskittcp when we are cancelling requests so it can properly close the socket
Modified:
trunk/reactos/drivers/network/tcpip/include/dispatch.h
trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c
trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c
Modified: trunk/reactos/drivers/network/tcpip/include/dispatch.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/incl…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/include/dispatch.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/include/dispatch.h [iso-8859-1] Sat Jun 27
07:23:10 2009
@@ -7,6 +7,12 @@
#ifndef __DISPATCH_H
#define __DISPATCH_H
+typedef struct _DISCONNECT_TYPE {
+ UINT Type;
+ PVOID Context;
+ PIRP Irp;
+ PFILE_OBJECT FileObject;
+} DISCONNECT_TYPE, *PDISCONNECT_TYPE;
NTSTATUS DispTdiAccept(
PIRP Irp);
@@ -64,6 +70,9 @@
PIRP Irp,
PIO_STACK_LOCATION IrpSp);
+VOID DispDoDisconnect(
+ PVOID Data);
+
#endif /* __DISPATCH_H */
/* EOF */
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 Jun 27 07:23:10
2009
@@ -110,13 +110,6 @@
TI_DbgPrint(DEBUG_IRP, ("Done Completing IRP\n"));
}
-
-typedef struct _DISCONNECT_TYPE {
- UINT Type;
- PVOID Context;
- PIRP Irp;
- PFILE_OBJECT FileObject;
-} DISCONNECT_TYPE, *PDISCONNECT_TYPE;
VOID DispDoDisconnect( PVOID Data ) {
PDISCONNECT_TYPE DisType = (PDISCONNECT_TYPE)Data;
@@ -250,6 +243,9 @@
/* Try canceling the request */
Connection = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext;
+
+ TCPRemoveIRP(Connection, Irp);
+
TCPAbortListenForSocket(
Connection->AddressFile->Listener,
Connection );
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 Jun 27 07:23:10
2009
@@ -217,24 +217,66 @@
}
if( NewState & SEL_FIN ) {
- PLIST_ENTRY ListsToErase[4];
- UINT i;
-
- TI_DbgPrint(DEBUG_TCP, ("EOF From socket\n"));
-
- ListsToErase[0] = &Connection->ReceiveRequest;
- ListsToErase[1] = &Connection->ListenRequest;
- ListsToErase[2] = &Connection->ConnectRequest;
- ListsToErase[3] = &Connection->SendRequest;
-
- for( i = 0; i < 4; i++ ) {
- while( !IsListEmpty( ListsToErase[i] ) ) {
- Entry = RemoveHeadList( ListsToErase[i] );
- Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
- Complete = Bucket->Request.RequestNotifyObject;
- Complete( Bucket->Request.RequestContext, STATUS_CANCELLED, 0 );
- exFreePool( Bucket );
- }
+ TI_DbgPrint(DEBUG_TCP, ("EOF From socket\n"));
+
+ while (!IsListEmpty(&Connection->ReceiveRequest))
+ {
+ DISCONNECT_TYPE DisType;
+ PIO_STACK_LOCATION IrpSp;
+ Entry = RemoveHeadList(&Connection->ReceiveRequest);
+ Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
+ Complete = Bucket->Request.RequestNotifyObject;
+ IrpSp =
IoGetCurrentIrpStackLocation((PIRP)Bucket->Request.RequestContext);
+
+ /* We have to notify oskittcp of the abortion */
+ DisType.Type = TDI_DISCONNECT_RELEASE | TDI_DISCONNECT_ABORT;
+ DisType.Context = Connection;
+ DisType.Irp = (PIRP)Bucket->Request.RequestContext;
+ DisType.FileObject = IrpSp->FileObject;
+
+ ChewCreate(NULL, sizeof(DISCONNECT_TYPE),
+ DispDoDisconnect, &DisType);
+ }
+
+ while (!IsListEmpty(&Connection->SendRequest))
+ {
+ DISCONNECT_TYPE DisType;
+ PIO_STACK_LOCATION IrpSp;
+ Entry = RemoveHeadList(&Connection->SendRequest);
+ Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
+ Complete = Bucket->Request.RequestNotifyObject;
+ IrpSp =
IoGetCurrentIrpStackLocation((PIRP)Bucket->Request.RequestContext);
+
+ /* We have to notify oskittcp of the abortion */
+ DisType.Type = TDI_DISCONNECT_RELEASE;
+ DisType.Context = Connection;
+ DisType.Irp = (PIRP)Bucket->Request.RequestContext;
+ DisType.FileObject = IrpSp->FileObject;
+
+ ChewCreate(NULL, sizeof(DISCONNECT_TYPE),
+ DispDoDisconnect, &DisType);
+ }
+
+ while (!IsListEmpty(&Connection->ListenRequest))
+ {
+ Entry = RemoveHeadList(&Connection->ListenRequest);
+ Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
+ Complete = Bucket->Request.RequestNotifyObject;
+
+ /* We have to notify oskittcp of the abortion */
+ TCPAbortListenForSocket(Connection->AddressFile->Listener,
+ Connection);
+
+ Complete( Bucket->Request.RequestContext, STATUS_CANCELLED, 0 );
+ }
+
+ while (!IsListEmpty(&Connection->ConnectRequest))
+ {
+ Entry = RemoveHeadList(&Connection->ConnectRequest);
+ Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
+ Complete = Bucket->Request.RequestNotifyObject;
+
+ Complete( Bucket->Request.RequestContext, STATUS_CANCELLED, 0 );
}
}
@@ -656,11 +698,11 @@
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
- Status = TCPTranslateError( OskitTCPClose( Connection->SocketContext ) );
-
/* Make our code remove all pending IRPs */
Connection->State |= SEL_FIN;
DrainSignals();
+
+ Status = TCPTranslateError( OskitTCPClose( Connection->SocketContext ) );
TcpipRecursiveMutexLeave( &TCPLock );