Author: cgutman
Date: Thu Jul 2 11:16:50 2009
New Revision: 41737
URL:
http://svn.reactos.org/svn/reactos?rev=41737&view=rev
Log:
- tcpip locking rewrite (part 1 of x)
- Use ExInterlocked list functions to manipulate the request lists
- Fix usage of the wrong lock to protect the listen request list
- Next step: Optimize usage of TCPLock
Modified:
trunk/reactos/lib/drivers/ip/transport/tcp/accept.c
trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c
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] Thu Jul 2 11:16:50
2009
@@ -106,8 +106,9 @@
PCONNECTION_ENDPOINT Connection ) {
PLIST_ENTRY ListEntry;
PTDI_BUCKET Bucket;
+ KIRQL OldIrql;
- TcpipRecursiveMutexEnter( &TCPLock, TRUE );
+ KeAcquireSpinLock(&Listener->Lock, &OldIrql);
ListEntry = Listener->ListenRequest.Flink;
while ( ListEntry != &Listener->ListenRequest ) {
@@ -122,7 +123,7 @@
ListEntry = ListEntry->Flink;
}
- TcpipRecursiveMutexLeave( &TCPLock );
+ KeReleaseSpinLock(&Listener->Lock, OldIrql);
}
NTSTATUS TCPAccept ( PTDI_REQUEST Request,
@@ -149,7 +150,7 @@
Bucket->Request.RequestNotifyObject = Complete;
Bucket->Request.RequestContext = Context;
IoMarkIrpPending((PIRP)Context);
- InsertTailList( &Listener->ListenRequest, &Bucket->Entry );
+ ExInterlockedInsertTailList( &Listener->ListenRequest,
&Bucket->Entry, &Listener->Lock );
} else
Status = STATUS_NO_MEMORY;
}
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] Thu Jul 2 11:16:50
2009
@@ -35,8 +35,9 @@
/* Things that can happen when we try the initial connection */
if( NewState & SEL_CONNECT ) {
- while( !IsListEmpty( &Connection->ConnectRequest ) ) {
- Entry = RemoveHeadList( &Connection->ConnectRequest );
+ while( (Entry = ExInterlockedRemoveHeadList( &Connection->ConnectRequest,
+ &Connection->Lock )) != NULL
) {
+
TI_DbgPrint(DEBUG_TCP, ("Connect Event\n"));
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
@@ -67,10 +68,10 @@
IsListEmpty(&Connection->ListenRequest) ?
"empty" : "nonempty"));
- while( !IsListEmpty( &Connection->ListenRequest ) ) {
+ while( (Entry = ExInterlockedRemoveHeadList( &Connection->ListenRequest,
+ &Connection->Lock )) != NULL
) {
PIO_STACK_LOCATION IrpSp;
- Entry = RemoveHeadList( &Connection->ListenRequest );
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
Complete = Bucket->Request.RequestNotifyObject;
@@ -86,7 +87,7 @@
TI_DbgPrint(DEBUG_TCP,("Socket: Status: %x\n"));
if( Status == STATUS_PENDING ) {
- InsertHeadList( &Connection->ListenRequest, &Bucket->Entry
);
+ ExInterlockedInsertHeadList( &Connection->ListenRequest,
&Bucket->Entry, &Connection->Lock );
break;
} else {
Complete( Bucket->Request.RequestContext, Status, 0 );
@@ -101,11 +102,11 @@
IsListEmpty(&Connection->ReceiveRequest) ?
"empty" : "nonempty"));
- while( !IsListEmpty( &Connection->ReceiveRequest ) ) {
+ while( (Entry = ExInterlockedRemoveHeadList( &Connection->ReceiveRequest,
+ &Connection->Lock )) != NULL
) {
OSK_UINT RecvLen = 0, Received = 0;
PVOID RecvBuffer = 0;
- Entry = RemoveHeadList( &Connection->ReceiveRequest );
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
Complete = Bucket->Request.RequestNotifyObject;
@@ -144,8 +145,8 @@
STATUS_SUCCESS, Received );
exFreePool( Bucket );
} else if( Status == STATUS_PENDING ) {
- InsertHeadList
- ( &Connection->ReceiveRequest, &Bucket->Entry );
+ ExInterlockedInsertHeadList
+ ( &Connection->ReceiveRequest, &Bucket->Entry,
&Connection->Lock );
break;
} else {
TI_DbgPrint(DEBUG_TCP,
@@ -161,11 +162,11 @@
IsListEmpty(&Connection->SendRequest) ?
"empty" : "nonempty"));
- while( !IsListEmpty( &Connection->SendRequest ) ) {
+ while( (Entry = ExInterlockedRemoveHeadList( &Connection->SendRequest,
+ &Connection->Lock )) != NULL
) {
OSK_UINT SendLen = 0, Sent = 0;
PVOID SendBuffer = 0;
- Entry = RemoveHeadList( &Connection->SendRequest );
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
Complete = Bucket->Request.RequestNotifyObject;
@@ -203,8 +204,8 @@
STATUS_SUCCESS, Sent );
exFreePool( Bucket );
} else if( Status == STATUS_PENDING ) {
- InsertHeadList
- ( &Connection->SendRequest, &Bucket->Entry );
+ ExInterlockedInsertHeadList
+ ( &Connection->SendRequest, &Bucket->Entry,
&Connection->Lock );
break;
} else {
TI_DbgPrint(DEBUG_TCP,
@@ -219,11 +220,11 @@
if( NewState & SEL_FIN ) {
TI_DbgPrint(DEBUG_TCP, ("EOF From socket\n"));
- while (!IsListEmpty(&Connection->ReceiveRequest))
+ while ((Entry = ExInterlockedRemoveHeadList( &Connection->ReceiveRequest,
+ &Connection->Lock )) !=
NULL)
{
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);
@@ -238,11 +239,11 @@
DispDoDisconnect, &DisType);
}
- while (!IsListEmpty(&Connection->SendRequest))
+ while ((Entry = ExInterlockedRemoveHeadList( &Connection->SendRequest,
+ &Connection->Lock )) !=
NULL)
{
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);
@@ -257,9 +258,9 @@
DispDoDisconnect, &DisType);
}
- while (!IsListEmpty(&Connection->ListenRequest))
+ while ((Entry = ExInterlockedRemoveHeadList( &Connection->ListenRequest,
+ &Connection->Lock )) !=
NULL)
{
- Entry = RemoveHeadList(&Connection->ListenRequest);
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
Complete = Bucket->Request.RequestNotifyObject;
@@ -270,9 +271,9 @@
Complete( Bucket->Request.RequestContext, STATUS_CANCELLED, 0 );
}
- while (!IsListEmpty(&Connection->ConnectRequest))
+ while ((Entry = ExInterlockedRemoveHeadList( &Connection->ConnectRequest,
+ &Connection->Lock )) !=
NULL)
{
- Entry = RemoveHeadList(&Connection->ConnectRequest);
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
Complete = Bucket->Request.RequestNotifyObject;
@@ -644,7 +645,7 @@
IoMarkIrpPending((PIRP)Context);
- InsertTailList( &Connection->ConnectRequest, &Bucket->Entry );
+ ExInterlockedInsertTailList( &Connection->ConnectRequest,
&Bucket->Entry, &Connection->Lock );
}
}
@@ -770,7 +771,7 @@
IoMarkIrpPending((PIRP)Context);
- InsertTailList( &Connection->ReceiveRequest, &Bucket->Entry );
+ ExInterlockedInsertTailList( &Connection->ReceiveRequest,
&Bucket->Entry, &Connection->Lock );
TI_DbgPrint(DEBUG_TCP,("Queued read irp\n"));
} else {
TI_DbgPrint(DEBUG_TCP,("Got status %x, bytes %d\n", Status,
Received));
@@ -838,7 +839,7 @@
IoMarkIrpPending((PIRP)Context);
- InsertTailList( &Connection->SendRequest, &Bucket->Entry );
+ ExInterlockedInsertTailList( &Connection->SendRequest,
&Bucket->Entry, &Connection->Lock );
TI_DbgPrint(DEBUG_TCP,("Queued write irp\n"));
} else {
TI_DbgPrint(DEBUG_TCP,("Got status %x, bytes %d\n", Status, Sent));