Author: cgutman Date: Mon Nov 2 22:28:25 2009 New Revision: 43926
URL: http://svn.reactos.org/svn/reactos?rev=43926&view=rev Log: - Rework our oskittcp signalling - SignalledConnectionsList is now only used for connections that have pending requests - Remove another unused member from CONNECTION_ENDPOINT
Modified: trunk/reactos/drivers/network/tcpip/include/tcp.h trunk/reactos/drivers/network/tcpip/include/titypes.h trunk/reactos/lib/drivers/ip/transport/tcp/event.c trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c
Modified: trunk/reactos/drivers/network/tcpip/include/tcp.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/inclu... ============================================================================== --- trunk/reactos/drivers/network/tcpip/include/tcp.h [iso-8859-1] (original) +++ trunk/reactos/drivers/network/tcpip/include/tcp.h [iso-8859-1] Mon Nov 2 22:28:25 2009 @@ -105,6 +105,7 @@ PVOID Context );
/* tcp.c */ +ULONG HandleSignalledConnection( PCONNECTION_ENDPOINT Connection ); PCONNECTION_ENDPOINT TCPAllocateConnectionEndpoint( PVOID ClientContext ); VOID TCPFreeConnectionEndpoint( PCONNECTION_ENDPOINT Connection );
Modified: trunk/reactos/drivers/network/tcpip/include/titypes.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/inclu... ============================================================================== --- trunk/reactos/drivers/network/tcpip/include/titypes.h [iso-8859-1] (original) +++ trunk/reactos/drivers/network/tcpip/include/titypes.h [iso-8859-1] Mon Nov 2 22:28:25 2009 @@ -309,7 +309,6 @@ LIST_ENTRY SignalList; /* Entry in the list of sockets waiting for * notification service to the client */ UINT SignalState; /* Active signals from oskit */ - BOOLEAN Signalled; /* Are we a member of the signal list */ } CONNECTION_ENDPOINT, *PCONNECTION_ENDPOINT;
Modified: trunk/reactos/lib/drivers/ip/transport/tcp/event.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/tc... ============================================================================== --- trunk/reactos/lib/drivers/ip/transport/tcp/event.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/ip/transport/tcp/event.c [iso-8859-1] Mon Nov 2 22:28:25 2009 @@ -15,6 +15,8 @@ void *WhichConnection, OSK_UINT NewState ) { PCONNECTION_ENDPOINT Connection = WhichConnection; + ULONG OldState; + KIRQL OldIrql;
ASSERT_LOCKED(&TCPLock);
@@ -38,14 +40,23 @@ TI_DbgPrint(DEBUG_TCP,("Found socket %x\n", Connection)); }
- TI_DbgPrint(MID_TRACE,("Connection signalled: %d\n", - Connection->Signalled)); + OldState = Connection->SignalState;
Connection->SignalState |= NewState; - if( !Connection->Signalled ) { - Connection->Signalled = TRUE; - ExInterlockedInsertTailList( &SignalledConnectionsList, &Connection->SignalList, &SignalledConnectionsLock ); - } + + NewState = HandleSignalledConnection(Connection); + + KeAcquireSpinLock(&SignalledConnectionsLock, &OldIrql); + if ((NewState == 0 || NewState == SEL_FIN) && + (OldState != 0 && OldState != SEL_FIN)) + { + RemoveEntryList(&Connection->SignalList); + } + else if (NewState != 0 && NewState != SEL_FIN) + { + InsertTailList(&SignalledConnectionsList, &Connection->SignalList); + } + KeReleaseSpinLock(&SignalledConnectionsLock, OldIrql);
return 0; }
Modified: trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/tc... ============================================================================== --- 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] Mon Nov 2 22:28:25 2009 @@ -22,7 +22,7 @@ RECURSIVE_MUTEX TCPLock; PORT_SET TCPPorts;
-static VOID HandleSignalledConnection( PCONNECTION_ENDPOINT Connection ) { +ULONG HandleSignalledConnection( PCONNECTION_ENDPOINT Connection ) { NTSTATUS Status = STATUS_SUCCESS; PTCP_COMPLETION_ROUTINE Complete; PTDI_BUCKET Bucket; @@ -38,6 +38,7 @@ if( Connection->SignalState & SEL_FIN ) { TI_DbgPrint(DEBUG_TCP, ("EOF From socket\n"));
+ Connection->SignalState &= ~SEL_READ; while ((Entry = ExInterlockedRemoveHeadList( &Connection->ReceiveRequest, &Connection->Lock )) != NULL) { @@ -49,6 +50,7 @@ exFreePool(Bucket); }
+ Connection->SignalState &= ~SEL_WRITE; while ((Entry = ExInterlockedRemoveHeadList( &Connection->SendRequest, &Connection->Lock )) != NULL) { @@ -60,6 +62,7 @@ exFreePool(Bucket); }
+ Connection->SignalState &= ~SEL_ACCEPT; while ((Entry = ExInterlockedRemoveHeadList( &Connection->ListenRequest, &Connection->Lock )) != NULL) { @@ -75,6 +78,7 @@ exFreePool(Bucket); }
+ Connection->SignalState &= ~SEL_CONNECT; while ((Entry = ExInterlockedRemoveHeadList( &Connection->ConnectRequest, &Connection->Lock )) != NULL) { @@ -85,12 +89,11 @@
exFreePool(Bucket); } - - Connection->SignalState = 0; }
/* Things that can happen when we try the initial connection */ if( Connection->SignalState & SEL_CONNECT ) { + Connection->SignalState &= ~SEL_CONNECT; while( (Entry = ExInterlockedRemoveHeadList( &Connection->ConnectRequest, &Connection->Lock )) != NULL ) {
@@ -118,6 +121,7 @@ IsListEmpty(&Connection->ListenRequest) ? "empty" : "nonempty"));
+ Connection->SignalState &= ~SEL_ACCEPT; while( (Entry = ExInterlockedRemoveHeadList( &Connection->ListenRequest, &Connection->Lock )) != NULL ) { PIO_STACK_LOCATION IrpSp; @@ -137,6 +141,7 @@ TI_DbgPrint(DEBUG_TCP,("Socket: Status: %x\n"));
if( Status == STATUS_PENDING ) { + Connection->SignalState |= SEL_ACCEPT; ExInterlockedInsertHeadList( &Connection->ListenRequest, &Bucket->Entry, &Connection->Lock ); break; } else { @@ -152,6 +157,7 @@ IsListEmpty(&Connection->ReceiveRequest) ? "empty" : "nonempty"));
+ Connection->SignalState &= ~SEL_READ; while( (Entry = ExInterlockedRemoveHeadList( &Connection->ReceiveRequest, &Connection->Lock )) != NULL ) { OSK_UINT RecvLen = 0, Received = 0; @@ -197,6 +203,7 @@ } else if( Status == STATUS_PENDING ) { ExInterlockedInsertHeadList ( &Connection->ReceiveRequest, &Bucket->Entry, &Connection->Lock ); + Connection->SignalState |= SEL_READ; break; } else { TI_DbgPrint(DEBUG_TCP, @@ -212,6 +219,7 @@ IsListEmpty(&Connection->SendRequest) ? "empty" : "nonempty"));
+ Connection->SignalState &= ~SEL_WRITE; while( (Entry = ExInterlockedRemoveHeadList( &Connection->SendRequest, &Connection->Lock )) != NULL ) { OSK_UINT SendLen = 0, Sent = 0; @@ -256,6 +264,7 @@ } else if( Status == STATUS_PENDING ) { ExInterlockedInsertHeadList ( &Connection->SendRequest, &Bucket->Entry, &Connection->Lock ); + Connection->SignalState |= SEL_WRITE; break; } else { TI_DbgPrint(DEBUG_TCP, @@ -267,20 +276,35 @@ } }
- Connection->SignalState = 0; - Connection->Signalled = FALSE; -} - -VOID DrainSignals() { + return Connection->SignalState; +} + +static VOID DrainSignals() { PCONNECTION_ENDPOINT Connection; - PLIST_ENTRY ListEntry; - - while( (ListEntry = ExInterlockedRemoveHeadList(&SignalledConnectionsList, - &SignalledConnectionsLock)) != NULL) { - Connection = CONTAINING_RECORD( ListEntry, CONNECTION_ENDPOINT, + PLIST_ENTRY CurrentEntry, NextEntry; + ULONG NewState; + KIRQL OldIrql; + + KeAcquireSpinLock(&SignalledConnectionsLock, &OldIrql); + CurrentEntry = SignalledConnectionsList.Flink; + while (CurrentEntry != &SignalledConnectionsList) + { + NextEntry = CurrentEntry->Flink; + Connection = CONTAINING_RECORD( CurrentEntry, CONNECTION_ENDPOINT, SignalList ); - HandleSignalledConnection( Connection ); - } + + KeReleaseSpinLock(&SignalledConnectionsLock, OldIrql); + NewState = HandleSignalledConnection(Connection); + KeAcquireSpinLock(&SignalledConnectionsLock, &OldIrql); + + if (NewState == SEL_FIN || NewState == 0) + { + RemoveEntryList(CurrentEntry); + } + + CurrentEntry = NextEntry; + } + KeReleaseSpinLock(&SignalledConnectionsLock, OldIrql); }
PCONNECTION_ENDPOINT TCPAllocateConnectionEndpoint( PVOID ClientContext ) { @@ -353,8 +377,6 @@ OskitTCPReceiveDatagram( IPPacket->Header, IPPacket->TotalSize, IPPacket->HeaderSize ); - - DrainSignals();
TcpipRecursiveMutexLeave( &TCPLock ); }