Author: cgutman
Date: Fri Jul 3 10:28:59 2009
New Revision: 41752
URL:
http://svn.reactos.org/svn/reactos?rev=41752&view=rev
Log:
- TCPIP lock rewrite (part 3 of 3)
- Use a spin lock to protect the signalled connections list
- Add a debug ASSERT into each function that depends on the TCPLock being held
- Release TCPLock before completing the IRP
- Add some locking where it was forgotten
- Optimize HandleSignalledConnection
Modified:
trunk/reactos/drivers/network/tcpip/include/tcp.h
trunk/reactos/drivers/network/tcpip/recmutex/recmutex.h
trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c
trunk/reactos/drivers/network/tcpip/tcpip/fileobjs.c
trunk/reactos/lib/drivers/ip/transport/tcp/accept.c
trunk/reactos/lib/drivers/ip/transport/tcp/event.c
trunk/reactos/lib/drivers/ip/transport/tcp/if.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/incl…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/include/tcp.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/include/tcp.h [iso-8859-1] Fri Jul 3 10:28:59
2009
@@ -84,7 +84,8 @@
#define SRF_FIN TCP_FIN
extern LONG TCP_IPIdentification;
-extern LIST_ENTRY SignalledConnections;
+extern LIST_ENTRY SignalledConnectionsList;
+extern KSPIN_LOCK SignalledConnectionsLock;
extern LIST_ENTRY SleepingThreadsList;
extern FAST_MUTEX SleepingThreadsLock;
extern RECURSIVE_MUTEX TCPLock;
Modified: trunk/reactos/drivers/network/tcpip/recmutex/recmutex.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/recm…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/recmutex/recmutex.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/recmutex/recmutex.h [iso-8859-1] Fri Jul 3
10:28:59 2009
@@ -24,4 +24,6 @@
extern SIZE_T RecursiveMutexEnter( PRECURSIVE_MUTEX RecMutex, BOOLEAN ToRead );
extern VOID RecursiveMutexLeave( PRECURSIVE_MUTEX RecMutex );
+#define ASSERT_LOCKED(x) ASSERT((x)->Locked)
+
#endif/*_ROSRTL_RECMUTEX_H*/
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] Fri Jul 3 10:28:59
2009
@@ -106,6 +106,7 @@
PDISCONNECT_TYPE DisType = (PDISCONNECT_TYPE)Data;
TI_DbgPrint(DEBUG_IRP, ("PostCancel: DoDisconnect\n"));
+ TcpipRecursiveMutexEnter(&TCPLock, TRUE);
TCPDisconnect
( DisType->Context,
DisType->Type,
@@ -113,6 +114,7 @@
NULL,
DispDataRequestComplete,
DisType->Irp );
+ TcpipRecursiveMutexLeave(&TCPLock);
TI_DbgPrint(DEBUG_IRP, ("PostCancel: DoDisconnect done\n"));
DispDataRequestComplete(DisType->Irp, STATUS_CANCELLED, 0);
@@ -405,12 +407,12 @@
Irp );
done:
+ TcpipRecursiveMutexLeave( &TCPLock );
+
if (Status != STATUS_PENDING) {
DispDataRequestComplete(Irp, Status, 0);
} else
IoMarkIrpPending(Irp);
-
- TcpipRecursiveMutexLeave( &TCPLock );
TI_DbgPrint(MAX_TRACE, ("TCP Connect returned %08x\n", Status));
@@ -513,12 +515,12 @@
Irp );
done:
+ TcpipRecursiveMutexLeave( &TCPLock );
+
if (Status != STATUS_PENDING) {
DispDataRequestComplete(Irp, Status, 0);
} else
IoMarkIrpPending(Irp);
-
- TcpipRecursiveMutexLeave( &TCPLock );
TI_DbgPrint(MAX_TRACE, ("TCP Disconnect returned %08x\n", Status));
@@ -618,12 +620,12 @@
}
done:
+ TcpipRecursiveMutexLeave( &TCPLock );
+
if (Status != STATUS_PENDING) {
DispDataRequestComplete(Irp, Status, 0);
} else
IoMarkIrpPending(Irp);
-
- TcpipRecursiveMutexLeave( &TCPLock );
TI_DbgPrint(MID_TRACE,("Leaving %x\n", Status));
@@ -834,12 +836,12 @@
}
done:
+ TcpipRecursiveMutexLeave( &TCPLock );
+
if (Status != STATUS_PENDING) {
DispDataRequestComplete(Irp, Status, BytesReceived);
} else
IoMarkIrpPending(Irp);
-
- TcpipRecursiveMutexLeave( &TCPLock );
TI_DbgPrint(DEBUG_IRP, ("Leaving. Status is (0x%X)\n", Status));
@@ -912,12 +914,12 @@
}
done:
+ TcpipRecursiveMutexLeave( &TCPLock );
+
if (Status != STATUS_PENDING) {
DispDataRequestComplete(Irp, Status, BytesReceived);
} else
IoMarkIrpPending(Irp);
-
- TcpipRecursiveMutexLeave( &TCPLock );
TI_DbgPrint(DEBUG_IRP, ("Leaving. Status is (0x%X)\n", Status));
@@ -988,12 +990,12 @@
}
done:
+ TcpipRecursiveMutexLeave( &TCPLock );
+
if (Status != STATUS_PENDING) {
DispDataRequestComplete(Irp, Status, BytesSent);
} else
IoMarkIrpPending(Irp);
-
- TcpipRecursiveMutexLeave( &TCPLock );
TI_DbgPrint(DEBUG_IRP, ("Leaving. Status is (0x%X)\n", Status));
@@ -1070,12 +1072,12 @@
}
done:
+ TcpipRecursiveMutexLeave( &TCPLock );
+
if (Status != STATUS_PENDING) {
DispDataRequestComplete(Irp, Status, Irp->IoStatus.Information);
} else
IoMarkIrpPending(Irp);
-
- TcpipRecursiveMutexLeave( &TCPLock );
TI_DbgPrint(DEBUG_IRP, ("Leaving.\n"));
Modified: trunk/reactos/drivers/network/tcpip/tcpip/fileobjs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/tcpi…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/tcpip/fileobjs.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/tcpip/fileobjs.c [iso-8859-1] Fri Jul 3 10:28:59
2009
@@ -363,7 +363,9 @@
case IPPROTO_TCP:
TCPFreePort( AddrFile->Port );
if( AddrFile->Listener ) {
+ TcpipRecursiveMutexEnter(&TCPLock, TRUE);
TCPClose( AddrFile->Listener );
+ TcpipRecursiveMutexLeave(&TCPLock);
exFreePool( AddrFile->Listener );
}
break;
@@ -425,7 +427,9 @@
if( !Connection ) return STATUS_NO_MEMORY;
+ TcpipRecursiveMutexEnter(&TCPLock, TRUE);
Status = TCPSocket( Connection, AF_INET, SOCK_STREAM, IPPROTO_TCP );
+ TcpipRecursiveMutexLeave(&TCPLock);
if( !NT_SUCCESS(Status) ) {
TCPFreeConnectionEndpoint( Connection );
Modified: trunk/reactos/lib/drivers/ip/transport/tcp/accept.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/t…
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/tcp/accept.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/transport/tcp/accept.c [iso-8859-1] Fri Jul 3 10:28:59
2009
@@ -18,6 +18,8 @@
OSK_UINT OutAddrLen;
PTA_IP_ADDRESS RequestAddressReturn;
PTDI_CONNECTION_INFORMATION WhoIsConnecting;
+
+ ASSERT_LOCKED(&TCPLock);
/* Unpack TDI info -- We need the return connection information
* struct to return the address so it can be filtered if needed
Modified: trunk/reactos/lib/drivers/ip/transport/tcp/event.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/t…
==============================================================================
--- 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] Fri Jul 3 10:28:59
2009
@@ -16,6 +16,8 @@
OSK_UINT NewState ) {
PCONNECTION_ENDPOINT Connection = WhichConnection;
+ ASSERT_LOCKED(&TCPLock);
+
TI_DbgPrint(MID_TRACE,("Flags: %c%c%c%c\n",
NewState & SEL_CONNECT ? 'C' : 'c',
NewState & SEL_READ ? 'R' : 'r',
@@ -42,7 +44,7 @@
Connection->SignalState |= NewState;
if( !Connection->Signalled ) {
Connection->Signalled = TRUE;
- InsertTailList( &SignalledConnections, &Connection->SignalList );
+ ExInterlockedInsertTailList( &SignalledConnectionsList,
&Connection->SignalList, &SignalledConnectionsLock );
}
return 0;
@@ -52,6 +54,8 @@
PNDIS_PACKET NdisPacket,
NDIS_STATUS NdisStatus ) {
TI_DbgPrint(DEBUG_TCP,("called %x\n", NdisPacket));
+ ASSERT_LOCKED(&TCPLock);
+
FreeNdisPacket(NdisPacket);
TI_DbgPrint(DEBUG_TCP,("done\n"));
}
@@ -64,6 +68,8 @@
IP_PACKET Packet = { 0 };
IP_ADDRESS RemoteAddress, LocalAddress;
PIPv4_HEADER Header;
+
+ ASSERT_LOCKED(&TCPLock);
if( *data == 0x45 ) { /* IPv4 */
Header = (PIPv4_HEADER)data;
@@ -114,6 +120,8 @@
PSLEEPING_THREAD SleepingThread;
LARGE_INTEGER Timeout;
+ ASSERT_LOCKED(&TCPLock);
+
TI_DbgPrint(DEBUG_TCP,
("Called TSLEEP: tok = %x, pri = %d, wmesg = %s, tmio = %x\n",
token, priority, msg, tmio));
@@ -158,6 +166,8 @@
void TCPWakeup( void *ClientData, void *token ) {
PLIST_ENTRY Entry;
PSLEEPING_THREAD SleepingThread;
+
+ ASSERT_LOCKED(&TCPLock);
TcpipAcquireFastMutex( &SleepingThreadsLock );
Entry = SleepingThreadsList.Flink;
@@ -222,6 +232,8 @@
OSK_UINT Bytes, OSK_PCHAR File, OSK_UINT Line ) {
void *v;
ULONG Signature;
+
+ ASSERT_LOCKED(&TCPLock);
#if 0 != MEM_PROFILE
static OSK_UINT *Sizes = NULL, *Counts = NULL, ArrayAllocated = 0;
@@ -298,6 +310,8 @@
void *data, OSK_PCHAR File, OSK_UINT Line ) {
ULONG Signature;
+ ASSERT_LOCKED(&TCPLock);
+
UntrackFL( (PCHAR)File, Line, data,
FOURCC('f','b','s','d') );
data = (void *)((char *) data - sizeof(ULONG));
Signature = *((ULONG *) data);
Modified: trunk/reactos/lib/drivers/ip/transport/tcp/if.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/t…
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/tcp/if.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/transport/tcp/if.c [iso-8859-1] Fri Jul 3 10:28:59 2009
@@ -34,6 +34,8 @@
NTSTATUS Status;
POSK_IFADDR ifaddr = IF->TCPContext;
ASSERT(ifaddr);
+
+ ASSERT_LOCKED(&TCPLock);
RtlZeroMemory(ifaddr, sizeof(OSK_IFADDR) + 2 * sizeof( struct sockaddr_in ));
@@ -77,6 +79,8 @@
struct sockaddr_in *addr_in = (struct sockaddr_in *)ReqAddr;
POSK_IFADDR InterfaceData;
+ ASSERT_LOCKED(&TCPLock);
+
TI_DbgPrint(DEBUG_TCPIF,("called for type %d\n", FindType));
if( !ReqAddr ) {
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] Fri Jul 3 10:28:59
2009
@@ -15,14 +15,14 @@
LONG TCP_IPIdentification = 0;
static BOOLEAN TCPInitialized = FALSE;
static NPAGED_LOOKASIDE_LIST TCPSegmentList;
-LIST_ENTRY SignalledConnections;
+LIST_ENTRY SignalledConnectionsList;
+KSPIN_LOCK SignalledConnectionsLock;
LIST_ENTRY SleepingThreadsList;
FAST_MUTEX SleepingThreadsLock;
RECURSIVE_MUTEX TCPLock;
PORT_SET TCPPorts;
-static VOID HandleSignalledConnection( PCONNECTION_ENDPOINT Connection,
- ULONG NewState ) {
+static VOID HandleSignalledConnection( PCONNECTION_ENDPOINT Connection ) {
NTSTATUS Status = STATUS_SUCCESS;
PTCP_COMPLETION_ROUTINE Complete;
PTDI_BUCKET Bucket;
@@ -30,11 +30,79 @@
PIRP Irp;
PMDL Mdl;
+ ASSERT_LOCKED(&TCPLock);
+
TI_DbgPrint(MID_TRACE,("Handling signalled state on %x (%x)\n",
Connection, Connection->SocketContext));
+ if( Connection->SignalState & SEL_FIN ) {
+ TI_DbgPrint(DEBUG_TCP, ("EOF From socket\n"));
+
+ while ((Entry = ExInterlockedRemoveHeadList( &Connection->ReceiveRequest,
+ &Connection->Lock )) !=
NULL)
+ {
+ DISCONNECT_TYPE DisType;
+ PIO_STACK_LOCATION IrpSp;
+ 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 ((Entry = ExInterlockedRemoveHeadList( &Connection->SendRequest,
+ &Connection->Lock )) !=
NULL)
+ {
+ DISCONNECT_TYPE DisType;
+ PIO_STACK_LOCATION IrpSp;
+ 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 ((Entry = ExInterlockedRemoveHeadList( &Connection->ListenRequest,
+ &Connection->Lock )) !=
NULL)
+ {
+ 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 ((Entry = ExInterlockedRemoveHeadList( &Connection->ConnectRequest,
+ &Connection->Lock )) !=
NULL)
+ {
+ Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
+ Complete = Bucket->Request.RequestNotifyObject;
+
+ Complete( Bucket->Request.RequestContext, STATUS_CANCELLED, 0 );
+ }
+
+ Connection->SignalState = 0;
+ }
+
/* Things that can happen when we try the initial connection */
- if( NewState & SEL_CONNECT ) {
+ if( Connection->SignalState & SEL_CONNECT ) {
while( (Entry = ExInterlockedRemoveHeadList( &Connection->ConnectRequest,
&Connection->Lock )) != NULL
) {
@@ -45,20 +113,14 @@
TI_DbgPrint(DEBUG_TCP,
("Completing Request %x\n",
Bucket->Request.RequestContext));
- if( (NewState & (SEL_CONNECT | SEL_FIN)) ==
- (SEL_CONNECT | SEL_FIN) )
- Status = STATUS_CONNECTION_REFUSED;
- else
- Status = STATUS_SUCCESS;
-
- Complete( Bucket->Request.RequestContext, Status, 0 );
+ Complete( Bucket->Request.RequestContext, STATUS_SUCCESS, 0 );
/* Frees the bucket allocated in TCPConnect */
exFreePool( Bucket );
}
}
- if( NewState & SEL_ACCEPT ) {
+ if( Connection->SignalState & SEL_ACCEPT ) {
/* Handle readable on a listening socket --
* TODO: Implement filtering
*/
@@ -97,7 +159,7 @@
}
/* Things that happen after we're connected */
- if( NewState & SEL_READ ) {
+ if( Connection->SignalState & SEL_READ ) {
TI_DbgPrint(DEBUG_TCP,("Readable: irp list %s\n",
IsListEmpty(&Connection->ReceiveRequest) ?
"empty" : "nonempty"));
@@ -157,7 +219,7 @@
}
}
}
- if( NewState & SEL_WRITE ) {
+ if( Connection->SignalState & SEL_WRITE ) {
TI_DbgPrint(DEBUG_TCP,("Writeable: irp list %s\n",
IsListEmpty(&Connection->SendRequest) ?
"empty" : "nonempty"));
@@ -217,70 +279,7 @@
}
}
- if( NewState & SEL_FIN ) {
- TI_DbgPrint(DEBUG_TCP, ("EOF From socket\n"));
-
- while ((Entry = ExInterlockedRemoveHeadList( &Connection->ReceiveRequest,
- &Connection->Lock )) !=
NULL)
- {
- DISCONNECT_TYPE DisType;
- PIO_STACK_LOCATION IrpSp;
- 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 ((Entry = ExInterlockedRemoveHeadList( &Connection->SendRequest,
- &Connection->Lock )) !=
NULL)
- {
- DISCONNECT_TYPE DisType;
- PIO_STACK_LOCATION IrpSp;
- 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 ((Entry = ExInterlockedRemoveHeadList( &Connection->ListenRequest,
- &Connection->Lock )) !=
NULL)
- {
- 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 ((Entry = ExInterlockedRemoveHeadList( &Connection->ConnectRequest,
- &Connection->Lock )) !=
NULL)
- {
- Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
- Complete = Bucket->Request.RequestNotifyObject;
-
- Complete( Bucket->Request.RequestContext, STATUS_CANCELLED, 0 );
- }
- }
-
+ Connection->SignalState = 0;
Connection->Signalled = FALSE;
}
@@ -288,11 +287,11 @@
PCONNECTION_ENDPOINT Connection;
PLIST_ENTRY ListEntry;
- while( !IsListEmpty( &SignalledConnections ) ) {
- ListEntry = RemoveHeadList( &SignalledConnections );
+ while( (ListEntry = ExInterlockedRemoveHeadList(&SignalledConnectionsList,
+ &SignalledConnectionsLock)) !=
NULL) {
Connection = CONTAINING_RECORD( ListEntry, CONNECTION_ENDPOINT,
SignalList );
- HandleSignalledConnection( Connection, Connection->SignalState );
+ HandleSignalledConnection( Connection );
}
}
@@ -327,6 +326,8 @@
NTSTATUS TCPSocket( PCONNECTION_ENDPOINT Connection,
UINT Family, UINT Type, UINT Proto ) {
NTSTATUS Status;
+
+ ASSERT_LOCKED(&TCPLock);
TI_DbgPrint(DEBUG_TCP,("Called: Connection %x, Family %d, Type %d, "
"Proto %d\n",
@@ -480,8 +481,9 @@
TcpipRecursiveMutexInit( &TCPLock );
ExInitializeFastMutex( &SleepingThreadsLock );
+ KeInitializeSpinLock( &SignalledConnectionsLock );
InitializeListHead( &SleepingThreadsList );
- InitializeListHead( &SignalledConnections );
+ InitializeListHead( &SignalledConnectionsList );
Status = TCPMemStartup();
if ( ! NT_SUCCESS(Status) ) {
return Status;
@@ -493,8 +495,10 @@
return Status;
}
+ TcpipRecursiveMutexEnter(&TCPLock, TRUE);
RegisterOskitTCPEventHandlers( &EventHandlers );
InitOskitTCP();
+ TcpipRecursiveMutexLeave(&TCPLock);
/* Register this protocol with IP layer */
IPRegisterProtocol(IPPROTO_TCP, TCPReceive);
@@ -581,6 +585,8 @@
TI_DbgPrint(DEBUG_TCP,("TCPConnect: Called\n"));
+ ASSERT_LOCKED(&TCPLock);
+
Status = AddrBuildAddress
((PTRANSPORT_ADDRESS)ConnInfo->RemoteAddress,
&RemoteAddress,
@@ -655,6 +661,8 @@
PVOID Context ) {
NTSTATUS Status;
+ ASSERT_LOCKED(&TCPLock);
+
TI_DbgPrint(DEBUG_TCP,("started\n"));
switch( Flags & (TDI_DISCONNECT_ABORT | TDI_DISCONNECT_RELEASE) ) {
@@ -685,6 +693,8 @@
NTSTATUS Status;
TI_DbgPrint(DEBUG_TCP,("TCPClose started\n"));
+
+ ASSERT_LOCKED(&TCPLock);
/* Make our code remove all pending IRPs */
Connection->State |= SEL_FIN;
@@ -713,6 +723,8 @@
TI_DbgPrint(DEBUG_TCP,("Called for %d bytes (on socket %x)\n",
ReceiveLength, Connection->SocketContext));
+ ASSERT_LOCKED(&TCPLock);
+
ASSERT_KM_POINTER(Connection->SocketContext);
/* Closing */
@@ -775,6 +787,8 @@
NTSTATUS Status;
PTDI_BUCKET Bucket;
+ ASSERT_LOCKED(&TCPLock);
+
TI_DbgPrint(DEBUG_TCP,("Called for %d bytes (on socket %x)\n",
SendLength, Connection->SocketContext));
@@ -851,6 +865,8 @@
OSK_UINT LocalAddress, RemoteAddress;
OSK_UI16 LocalPort, RemotePort;
PTA_IP_ADDRESS AddressIP = (PTA_IP_ADDRESS)Address;
+
+ ASSERT_LOCKED(&TCPLock);
OskitTCPGetAddress
( Connection->SocketContext,