mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Use the recursive mutex to lock the TCP.
svn path=/trunk/; revision=11057
This commit is contained in:
parent
1eb1e27110
commit
e1741d6626
3 changed files with 18 additions and 34 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <rosrtl/string.h>
|
#include <rosrtl/string.h>
|
||||||
|
#include <rosrtl/recmutex.h>
|
||||||
#include <roscfg.h>
|
#include <roscfg.h>
|
||||||
#include <tcpip.h>
|
#include <tcpip.h>
|
||||||
#include <loopback.h>
|
#include <loopback.h>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $Id: makefile,v 1.21 2004/09/25 20:23:59 arty Exp $
|
# $Id: makefile,v 1.22 2004/09/25 21:32:56 arty Exp $
|
||||||
|
|
||||||
PATH_TO_TOP = ../../..
|
PATH_TO_TOP = ../../..
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ TARGET_PCH = include/precomp.h
|
||||||
TARGET_CFLAGS = \
|
TARGET_CFLAGS = \
|
||||||
-D__USE_W32API \
|
-D__USE_W32API \
|
||||||
-DNDIS40 \
|
-DNDIS40 \
|
||||||
-DMEMTRACK \
|
|
||||||
-Wall -Werror \
|
-Wall -Werror \
|
||||||
-I./include \
|
-I./include \
|
||||||
-I$(PATH_TO_TOP)/drivers/lib/oskittcp/include \
|
-I$(PATH_TO_TOP)/drivers/lib/oskittcp/include \
|
||||||
|
|
|
@ -15,7 +15,7 @@ static BOOLEAN TCPInitialized = FALSE;
|
||||||
static NPAGED_LOOKASIDE_LIST TCPSegmentList;
|
static NPAGED_LOOKASIDE_LIST TCPSegmentList;
|
||||||
LIST_ENTRY SleepingThreadsList;
|
LIST_ENTRY SleepingThreadsList;
|
||||||
FAST_MUTEX SleepingThreadsLock;
|
FAST_MUTEX SleepingThreadsLock;
|
||||||
FAST_MUTEX TCPLock;
|
RECURSIVE_MUTEX TCPLock;
|
||||||
|
|
||||||
VOID TCPReceive(PNET_TABLE_ENTRY NTE, PIP_PACKET IPPacket)
|
VOID TCPReceive(PNET_TABLE_ENTRY NTE, PIP_PACKET IPPacket)
|
||||||
/*
|
/*
|
||||||
|
@ -31,13 +31,13 @@ VOID TCPReceive(PNET_TABLE_ENTRY NTE, PIP_PACKET IPPacket)
|
||||||
IPPacket->TotalSize,
|
IPPacket->TotalSize,
|
||||||
IPPacket->HeaderSize));
|
IPPacket->HeaderSize));
|
||||||
|
|
||||||
ExAcquireFastMutex( &TCPLock );
|
RecursiveMutexEnter( &TCPLock, TRUE );
|
||||||
|
|
||||||
OskitTCPReceiveDatagram( IPPacket->Header,
|
OskitTCPReceiveDatagram( IPPacket->Header,
|
||||||
IPPacket->TotalSize,
|
IPPacket->TotalSize,
|
||||||
IPPacket->HeaderSize );
|
IPPacket->HeaderSize );
|
||||||
|
|
||||||
ExReleaseFastMutex( &TCPLock );
|
RecursiveMutexLeave( &TCPLock );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* event.c */
|
/* event.c */
|
||||||
|
@ -83,7 +83,7 @@ NTSTATUS TCPStartup(VOID)
|
||||||
* Status of operation
|
* Status of operation
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
ExInitializeFastMutex( &TCPLock );
|
RecursiveMutexInit( &TCPLock );
|
||||||
ExInitializeFastMutex( &SleepingThreadsLock );
|
ExInitializeFastMutex( &SleepingThreadsLock );
|
||||||
InitializeListHead( &SleepingThreadsList );
|
InitializeListHead( &SleepingThreadsList );
|
||||||
|
|
||||||
|
@ -186,7 +186,6 @@ NTSTATUS TCPConnect
|
||||||
( PTDI_REQUEST Request,
|
( PTDI_REQUEST Request,
|
||||||
PTDI_CONNECTION_INFORMATION ConnInfo,
|
PTDI_CONNECTION_INFORMATION ConnInfo,
|
||||||
PTDI_CONNECTION_INFORMATION ReturnInfo ) {
|
PTDI_CONNECTION_INFORMATION ReturnInfo ) {
|
||||||
KIRQL OldIrql;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
SOCKADDR_IN AddressToConnect = { 0 }, AddressToBind = { 0 };
|
SOCKADDR_IN AddressToConnect = { 0 }, AddressToBind = { 0 };
|
||||||
PCONNECTION_ENDPOINT Connection = Request->Handle.ConnectionContext;
|
PCONNECTION_ENDPOINT Connection = Request->Handle.ConnectionContext;
|
||||||
|
@ -199,8 +198,7 @@ NTSTATUS TCPConnect
|
||||||
Bucket = ExAllocatePool( NonPagedPool, sizeof(*Bucket) );
|
Bucket = ExAllocatePool( NonPagedPool, sizeof(*Bucket) );
|
||||||
if( !Bucket ) return STATUS_NO_MEMORY;
|
if( !Bucket ) return STATUS_NO_MEMORY;
|
||||||
|
|
||||||
ExAcquireFastMutex( &TCPLock );
|
RecursiveMutexEnter( &TCPLock, TRUE );
|
||||||
KeAcquireSpinLock(&Connection->Lock, &OldIrql);
|
|
||||||
|
|
||||||
/* Freed in TCPSocketState */
|
/* Freed in TCPSocketState */
|
||||||
Bucket->Request = *Request;
|
Bucket->Request = *Request;
|
||||||
|
@ -217,7 +215,6 @@ NTSTATUS TCPConnect
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status)) {
|
if (!NT_SUCCESS(Status)) {
|
||||||
TI_DbgPrint(MID_TRACE, ("Could not AddrBuildAddress in TCPConnect\n"));
|
TI_DbgPrint(MID_TRACE, ("Could not AddrBuildAddress in TCPConnect\n"));
|
||||||
KeReleaseSpinLock(&Connection->Lock, OldIrql);
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,8 +236,7 @@ NTSTATUS TCPConnect
|
||||||
&AddressToConnect,
|
&AddressToConnect,
|
||||||
sizeof(AddressToConnect));
|
sizeof(AddressToConnect));
|
||||||
|
|
||||||
KeReleaseSpinLock(&Connection->Lock, OldIrql);
|
RecursiveMutexLeave( &TCPLock );
|
||||||
ExReleaseFastMutex( &TCPLock );
|
|
||||||
|
|
||||||
if( Status == OSK_EINPROGRESS || Status == STATUS_SUCCESS )
|
if( Status == OSK_EINPROGRESS || Status == STATUS_SUCCESS )
|
||||||
return STATUS_PENDING;
|
return STATUS_PENDING;
|
||||||
|
@ -250,20 +246,17 @@ NTSTATUS TCPConnect
|
||||||
|
|
||||||
NTSTATUS TCPClose
|
NTSTATUS TCPClose
|
||||||
( PTDI_REQUEST Request ) {
|
( PTDI_REQUEST Request ) {
|
||||||
KIRQL OldIrql;
|
|
||||||
PCONNECTION_ENDPOINT Connection;
|
PCONNECTION_ENDPOINT Connection;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
Connection = Request->Handle.ConnectionContext;
|
Connection = Request->Handle.ConnectionContext;
|
||||||
|
|
||||||
TI_DbgPrint(MID_TRACE,("TCPClose started\n"));
|
TI_DbgPrint(MID_TRACE,("TCPClose started\n"));
|
||||||
|
|
||||||
ExAcquireFastMutex( &TCPLock );
|
RecursiveMutexEnter( &TCPLock, TRUE );
|
||||||
KeAcquireSpinLock(&Connection->Lock, &OldIrql);
|
|
||||||
|
|
||||||
Status = TCPTranslateError( OskitTCPClose( Connection->SocketContext ) );
|
Status = TCPTranslateError( OskitTCPClose( Connection->SocketContext ) );
|
||||||
|
|
||||||
KeReleaseSpinLock(&Connection->Lock, OldIrql);
|
RecursiveMutexLeave( &TCPLock );
|
||||||
ExReleaseFastMutex( &TCPLock );
|
|
||||||
|
|
||||||
TI_DbgPrint(MID_TRACE,("TCPClose finished %x\n", Status));
|
TI_DbgPrint(MID_TRACE,("TCPClose finished %x\n", Status));
|
||||||
|
|
||||||
|
@ -275,18 +268,15 @@ NTSTATUS TCPListen
|
||||||
UINT Backlog ) {
|
UINT Backlog ) {
|
||||||
PCONNECTION_ENDPOINT Connection;
|
PCONNECTION_ENDPOINT Connection;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
KIRQL OldIrql;
|
|
||||||
|
|
||||||
Connection = Request->Handle.ConnectionContext;
|
Connection = Request->Handle.ConnectionContext;
|
||||||
|
|
||||||
ExAcquireFastMutex( &TCPLock );
|
RecursiveMutexEnter( &TCPLock, TRUE );
|
||||||
KeAcquireSpinLock(&Connection->Lock, &OldIrql);
|
|
||||||
|
|
||||||
Status = TCPTranslateError( OskitTCPListen( Connection->SocketContext,
|
Status = TCPTranslateError( OskitTCPListen( Connection->SocketContext,
|
||||||
Backlog ) );
|
Backlog ) );
|
||||||
|
|
||||||
KeReleaseSpinLock(&Connection->Lock, OldIrql);
|
RecursiveMutexLeave( &TCPLock );
|
||||||
ExReleaseFastMutex( &TCPLock );
|
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -303,7 +293,6 @@ NTSTATUS TCPReceiveData
|
||||||
ULONG ReceiveLength,
|
ULONG ReceiveLength,
|
||||||
ULONG ReceiveFlags,
|
ULONG ReceiveFlags,
|
||||||
PULONG BytesReceived ) {
|
PULONG BytesReceived ) {
|
||||||
KIRQL OldIrql;
|
|
||||||
PCONNECTION_ENDPOINT Connection;
|
PCONNECTION_ENDPOINT Connection;
|
||||||
PCHAR DataBuffer;
|
PCHAR DataBuffer;
|
||||||
UINT DataLen, Received = 0;
|
UINT DataLen, Received = 0;
|
||||||
|
@ -314,8 +303,7 @@ NTSTATUS TCPReceiveData
|
||||||
|
|
||||||
Connection = Request->Handle.ConnectionContext;
|
Connection = Request->Handle.ConnectionContext;
|
||||||
|
|
||||||
ExAcquireFastMutex( &TCPLock );
|
RecursiveMutexEnter( &TCPLock, TRUE );
|
||||||
KeAcquireSpinLock(&Connection->Lock, &OldIrql);
|
|
||||||
|
|
||||||
NdisQueryBuffer( Buffer, &DataBuffer, &DataLen );
|
NdisQueryBuffer( Buffer, &DataBuffer, &DataLen );
|
||||||
|
|
||||||
|
@ -351,8 +339,7 @@ NTSTATUS TCPReceiveData
|
||||||
*BytesReceived = Received;
|
*BytesReceived = Received;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeReleaseSpinLock(&Connection->Lock, OldIrql);
|
RecursiveMutexLeave( &TCPLock );
|
||||||
ExReleaseFastMutex( &TCPLock );
|
|
||||||
|
|
||||||
TI_DbgPrint(MID_TRACE,("Status %x\n", Status));
|
TI_DbgPrint(MID_TRACE,("Status %x\n", Status));
|
||||||
|
|
||||||
|
@ -365,7 +352,6 @@ NTSTATUS TCPSendData
|
||||||
ULONG DataSize,
|
ULONG DataSize,
|
||||||
ULONG Flags,
|
ULONG Flags,
|
||||||
PULONG DataUsed ) {
|
PULONG DataUsed ) {
|
||||||
KIRQL OldIrql;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PCONNECTION_ENDPOINT Connection;
|
PCONNECTION_ENDPOINT Connection;
|
||||||
PCHAR BufferData;
|
PCHAR BufferData;
|
||||||
|
@ -373,8 +359,7 @@ NTSTATUS TCPSendData
|
||||||
|
|
||||||
Connection = Request->Handle.ConnectionContext;
|
Connection = Request->Handle.ConnectionContext;
|
||||||
|
|
||||||
ExAcquireFastMutex( &TCPLock );
|
RecursiveMutexEnter( &TCPLock, TRUE );
|
||||||
KeAcquireSpinLock(&Connection->Lock, &OldIrql);
|
|
||||||
|
|
||||||
NdisQueryBuffer( Buffer, &BufferData, &PacketSize );
|
NdisQueryBuffer( Buffer, &BufferData, &PacketSize );
|
||||||
|
|
||||||
|
@ -387,8 +372,7 @@ NTSTATUS TCPSendData
|
||||||
Status = OskitTCPSend( Connection->SocketContext,
|
Status = OskitTCPSend( Connection->SocketContext,
|
||||||
BufferData, PacketSize, (PUINT)DataUsed, 0 );
|
BufferData, PacketSize, (PUINT)DataUsed, 0 );
|
||||||
|
|
||||||
KeReleaseSpinLock(&Connection->Lock, OldIrql);
|
RecursiveMutexLeave( &TCPLock );
|
||||||
ExReleaseFastMutex( &TCPLock );
|
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -396,9 +380,9 @@ NTSTATUS TCPSendData
|
||||||
VOID TCPTimeout(VOID) {
|
VOID TCPTimeout(VOID) {
|
||||||
static int Times = 0;
|
static int Times = 0;
|
||||||
if( (Times++ % 5) == 0 ) {
|
if( (Times++ % 5) == 0 ) {
|
||||||
ExAcquireFastMutex( &TCPLock );
|
RecursiveMutexEnter( &TCPLock, TRUE );
|
||||||
TimerOskitTCP();
|
TimerOskitTCP();
|
||||||
ExReleaseFastMutex( &TCPLock );
|
RecursiveMutexLeave( &TCPLock );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue