mirror of
https://github.com/reactos/reactos.git
synced 2025-01-04 21:38:43 +00:00
Some improvements I've been sitting on.
Set SEL_FIN if we need to in TCPReceiveData. Clear out pending IRP queues properly when shutting down. Lock the tcp when getting or setting the address. svn path=/trunk/; revision=13961
This commit is contained in:
parent
e58c615243
commit
724d399a3f
1 changed files with 26 additions and 41 deletions
|
@ -155,16 +155,29 @@ static VOID HandleSignalledConnection( PCONNECTION_ENDPOINT Connection,
|
||||||
}
|
}
|
||||||
|
|
||||||
if( NewState & SEL_FIN ) {
|
if( NewState & SEL_FIN ) {
|
||||||
|
PLIST_ENTRY ListsToErase[4];
|
||||||
|
NTSTATUS IrpStatus[4];
|
||||||
|
UINT i;
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_TCP, ("EOF From socket\n"));
|
TI_DbgPrint(DEBUG_TCP, ("EOF From socket\n"));
|
||||||
|
|
||||||
while( !IsListEmpty( &Connection->ReceiveRequest ) ) {
|
ListsToErase[0] = &Connection->ReceiveRequest;
|
||||||
Entry = RemoveHeadList( &Connection->ReceiveRequest );
|
IrpStatus [0] = STATUS_SUCCESS;
|
||||||
|
ListsToErase[1] = &Connection->ListenRequest;
|
||||||
|
IrpStatus [1] = STATUS_UNSUCCESSFUL;
|
||||||
|
ListsToErase[2] = &Connection->ConnectRequest;
|
||||||
|
IrpStatus [2] = STATUS_UNSUCCESSFUL;
|
||||||
|
ListsToErase[3] = 0;
|
||||||
|
|
||||||
|
for( i = 0; ListsToErase[i]; i++ ) {
|
||||||
|
while( !IsListEmpty( ListsToErase[i] ) ) {
|
||||||
|
Entry = RemoveHeadList( ListsToErase[i] );
|
||||||
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
|
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
|
||||||
Complete = Bucket->Request.RequestNotifyObject;
|
Complete = Bucket->Request.RequestNotifyObject;
|
||||||
|
|
||||||
Complete( Bucket->Request.RequestContext, STATUS_SUCCESS, 0 );
|
Complete( Bucket->Request.RequestContext, STATUS_SUCCESS, 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Connection->Signalled = FALSE;
|
Connection->Signalled = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -371,39 +384,6 @@ NTSTATUS TCPTranslateError( int OskitError ) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
NTSTATUS TCPBind
|
|
||||||
( PCONNECTION_ENDPOINT Connection,
|
|
||||||
PTDI_CONNECTION_INFORMATION ConnInfo ) {
|
|
||||||
NTSTATUS Status;
|
|
||||||
SOCKADDR_IN AddressToConnect;
|
|
||||||
PIP_ADDRESS LocalAddress;
|
|
||||||
USHORT LocalPort;
|
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_TCP,("Called\n"));
|
|
||||||
|
|
||||||
Status = AddrBuildAddress
|
|
||||||
((PTA_ADDRESS)ConnInfo->LocalAddress,
|
|
||||||
&LocalAddress,
|
|
||||||
&LocalPort);
|
|
||||||
|
|
||||||
AddressToBind.sin_family = AF_INET;
|
|
||||||
memcpy( &AddressToBind.sin_addr,
|
|
||||||
&LocalAddress->Address.IPv4Address,
|
|
||||||
sizeof(AddressToBind.sin_addr) );
|
|
||||||
AddressToBind.sin_port = LocalPort;
|
|
||||||
|
|
||||||
Status = OskitTCPBind( Connection->SocketContext,
|
|
||||||
Connection,
|
|
||||||
&AddressToBind,
|
|
||||||
sizeof(AddressToBind));
|
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_TCP,("Leaving %x\n", Status));
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
NTSTATUS TCPConnect
|
NTSTATUS TCPConnect
|
||||||
( PCONNECTION_ENDPOINT Connection,
|
( PCONNECTION_ENDPOINT Connection,
|
||||||
PTDI_CONNECTION_INFORMATION ConnInfo,
|
PTDI_CONNECTION_INFORMATION ConnInfo,
|
||||||
|
@ -518,8 +498,9 @@ NTSTATUS TCPClose
|
||||||
|
|
||||||
Status = TCPTranslateError( OskitTCPClose( Connection->SocketContext ) );
|
Status = TCPTranslateError( OskitTCPClose( Connection->SocketContext ) );
|
||||||
|
|
||||||
if( Connection->Signalled )
|
/* Make our code remove all pending IRPs */
|
||||||
RemoveEntryList( &Connection->SignalList );
|
Connection->State |= SEL_FIN;
|
||||||
|
DrainSignals();
|
||||||
|
|
||||||
TcpipRecursiveMutexLeave( &TCPLock );
|
TcpipRecursiveMutexLeave( &TCPLock );
|
||||||
|
|
||||||
|
@ -648,6 +629,8 @@ NTSTATUS TCPGetPeerAddress
|
||||||
OSK_UI16 LocalPort, RemotePort;
|
OSK_UI16 LocalPort, RemotePort;
|
||||||
PTA_IP_ADDRESS AddressIP = (PTA_IP_ADDRESS)Address;
|
PTA_IP_ADDRESS AddressIP = (PTA_IP_ADDRESS)Address;
|
||||||
|
|
||||||
|
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
||||||
|
|
||||||
OskitTCPGetAddress
|
OskitTCPGetAddress
|
||||||
( Connection->SocketContext,
|
( Connection->SocketContext,
|
||||||
&LocalAddress, &LocalPort,
|
&LocalAddress, &LocalPort,
|
||||||
|
@ -659,6 +642,8 @@ NTSTATUS TCPGetPeerAddress
|
||||||
AddressIP->Address[0].Address[0].sin_port = RemotePort;
|
AddressIP->Address[0].Address[0].sin_port = RemotePort;
|
||||||
AddressIP->Address[0].Address[0].in_addr = RemoteAddress;
|
AddressIP->Address[0].Address[0].in_addr = RemoteAddress;
|
||||||
|
|
||||||
|
TcpipRecursiveMutexLeave( &TCPLock );
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue