mirror of
https://github.com/reactos/reactos.git
synced 2025-07-27 19:41:40 +00:00
- 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 svn path=/trunk/; revision=41630
This commit is contained in:
parent
97d8658da9
commit
dabb3e9f98
3 changed files with 71 additions and 24 deletions
|
@ -7,6 +7,12 @@
|
||||||
#ifndef __DISPATCH_H
|
#ifndef __DISPATCH_H
|
||||||
#define __DISPATCH_H
|
#define __DISPATCH_H
|
||||||
|
|
||||||
|
typedef struct _DISCONNECT_TYPE {
|
||||||
|
UINT Type;
|
||||||
|
PVOID Context;
|
||||||
|
PIRP Irp;
|
||||||
|
PFILE_OBJECT FileObject;
|
||||||
|
} DISCONNECT_TYPE, *PDISCONNECT_TYPE;
|
||||||
|
|
||||||
NTSTATUS DispTdiAccept(
|
NTSTATUS DispTdiAccept(
|
||||||
PIRP Irp);
|
PIRP Irp);
|
||||||
|
@ -64,6 +70,9 @@ NTSTATUS DispTdiDeleteIPAddress(
|
||||||
PIRP Irp,
|
PIRP Irp,
|
||||||
PIO_STACK_LOCATION IrpSp);
|
PIO_STACK_LOCATION IrpSp);
|
||||||
|
|
||||||
|
VOID DispDoDisconnect(
|
||||||
|
PVOID Data);
|
||||||
|
|
||||||
#endif /* __DISPATCH_H */
|
#endif /* __DISPATCH_H */
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -111,13 +111,6 @@ VOID DispDataRequestComplete(
|
||||||
TI_DbgPrint(DEBUG_IRP, ("Done Completing IRP\n"));
|
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 ) {
|
VOID DispDoDisconnect( PVOID Data ) {
|
||||||
PDISCONNECT_TYPE DisType = (PDISCONNECT_TYPE)Data;
|
PDISCONNECT_TYPE DisType = (PDISCONNECT_TYPE)Data;
|
||||||
|
|
||||||
|
@ -250,6 +243,9 @@ VOID NTAPI DispCancelListenRequest(
|
||||||
|
|
||||||
/* Try canceling the request */
|
/* Try canceling the request */
|
||||||
Connection = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext;
|
Connection = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext;
|
||||||
|
|
||||||
|
TCPRemoveIRP(Connection, Irp);
|
||||||
|
|
||||||
TCPAbortListenForSocket(
|
TCPAbortListenForSocket(
|
||||||
Connection->AddressFile->Listener,
|
Connection->AddressFile->Listener,
|
||||||
Connection );
|
Connection );
|
||||||
|
|
|
@ -217,24 +217,66 @@ static VOID HandleSignalledConnection( PCONNECTION_ENDPOINT Connection,
|
||||||
}
|
}
|
||||||
|
|
||||||
if( NewState & SEL_FIN ) {
|
if( NewState & SEL_FIN ) {
|
||||||
PLIST_ENTRY ListsToErase[4];
|
TI_DbgPrint(DEBUG_TCP, ("EOF From socket\n"));
|
||||||
UINT i;
|
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
ListsToErase[0] = &Connection->ReceiveRequest;
|
/* We have to notify oskittcp of the abortion */
|
||||||
ListsToErase[1] = &Connection->ListenRequest;
|
DisType.Type = TDI_DISCONNECT_RELEASE | TDI_DISCONNECT_ABORT;
|
||||||
ListsToErase[2] = &Connection->ConnectRequest;
|
DisType.Context = Connection;
|
||||||
ListsToErase[3] = &Connection->SendRequest;
|
DisType.Irp = (PIRP)Bucket->Request.RequestContext;
|
||||||
|
DisType.FileObject = IrpSp->FileObject;
|
||||||
|
|
||||||
for( i = 0; i < 4; i++ ) {
|
ChewCreate(NULL, sizeof(DISCONNECT_TYPE),
|
||||||
while( !IsListEmpty( ListsToErase[i] ) ) {
|
DispDoDisconnect, &DisType);
|
||||||
Entry = RemoveHeadList( ListsToErase[i] );
|
}
|
||||||
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
|
|
||||||
Complete = Bucket->Request.RequestNotifyObject;
|
while (!IsListEmpty(&Connection->SendRequest))
|
||||||
Complete( Bucket->Request.RequestContext, STATUS_CANCELLED, 0 );
|
{
|
||||||
exFreePool( Bucket );
|
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,12 +698,12 @@ NTSTATUS TCPClose
|
||||||
|
|
||||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
||||||
|
|
||||||
Status = TCPTranslateError( OskitTCPClose( Connection->SocketContext ) );
|
|
||||||
|
|
||||||
/* Make our code remove all pending IRPs */
|
/* Make our code remove all pending IRPs */
|
||||||
Connection->State |= SEL_FIN;
|
Connection->State |= SEL_FIN;
|
||||||
DrainSignals();
|
DrainSignals();
|
||||||
|
|
||||||
|
Status = TCPTranslateError( OskitTCPClose( Connection->SocketContext ) );
|
||||||
|
|
||||||
TcpipRecursiveMutexLeave( &TCPLock );
|
TcpipRecursiveMutexLeave( &TCPLock );
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_TCP,("TCPClose finished %x\n", Status));
|
TI_DbgPrint(DEBUG_TCP,("TCPClose finished %x\n", Status));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue