Previously checked in with some detritus from some experimental rtl stuff.

Fixed.

svn path=/trunk/; revision=11052
This commit is contained in:
Art Yerkes 2004-09-25 20:38:46 +00:00
parent 3725308f3e
commit 91fea9194d
2 changed files with 18 additions and 2 deletions

View file

@ -1,7 +1,6 @@
#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>

View file

@ -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;
RECURSIVE_MUTEX TcpMutex; FAST_MUTEX TCPLock;
VOID TCPReceive(PNET_TABLE_ENTRY NTE, PIP_PACKET IPPacket) VOID TCPReceive(PNET_TABLE_ENTRY NTE, PIP_PACKET IPPacket)
/* /*
@ -31,9 +31,13 @@ VOID TCPReceive(PNET_TABLE_ENTRY NTE, PIP_PACKET IPPacket)
IPPacket->TotalSize, IPPacket->TotalSize,
IPPacket->HeaderSize)); IPPacket->HeaderSize));
ExAcquireFastMutex( &TCPLock );
OskitTCPReceiveDatagram( IPPacket->Header, OskitTCPReceiveDatagram( IPPacket->Header,
IPPacket->TotalSize, IPPacket->TotalSize,
IPPacket->HeaderSize ); IPPacket->HeaderSize );
ExReleaseFastMutex( &TCPLock );
} }
/* event.c */ /* event.c */
@ -79,6 +83,7 @@ NTSTATUS TCPStartup(VOID)
* Status of operation * Status of operation
*/ */
{ {
ExInitializeFastMutex( &TCPLock );
ExInitializeFastMutex( &SleepingThreadsLock ); ExInitializeFastMutex( &SleepingThreadsLock );
InitializeListHead( &SleepingThreadsList ); InitializeListHead( &SleepingThreadsList );
@ -194,6 +199,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 );
KeAcquireSpinLock(&Connection->Lock, &OldIrql); KeAcquireSpinLock(&Connection->Lock, &OldIrql);
/* Freed in TCPSocketState */ /* Freed in TCPSocketState */
@ -234,6 +240,7 @@ NTSTATUS TCPConnect
sizeof(AddressToConnect)); sizeof(AddressToConnect));
KeReleaseSpinLock(&Connection->Lock, OldIrql); KeReleaseSpinLock(&Connection->Lock, OldIrql);
ExReleaseFastMutex( &TCPLock );
if( Status == OSK_EINPROGRESS || Status == STATUS_SUCCESS ) if( Status == OSK_EINPROGRESS || Status == STATUS_SUCCESS )
return STATUS_PENDING; return STATUS_PENDING;
@ -250,11 +257,13 @@ NTSTATUS TCPClose
TI_DbgPrint(MID_TRACE,("TCPClose started\n")); TI_DbgPrint(MID_TRACE,("TCPClose started\n"));
ExAcquireFastMutex( &TCPLock );
KeAcquireSpinLock(&Connection->Lock, &OldIrql); KeAcquireSpinLock(&Connection->Lock, &OldIrql);
Status = TCPTranslateError( OskitTCPClose( Connection->SocketContext ) ); Status = TCPTranslateError( OskitTCPClose( Connection->SocketContext ) );
KeReleaseSpinLock(&Connection->Lock, OldIrql); KeReleaseSpinLock(&Connection->Lock, OldIrql);
ExReleaseFastMutex( &TCPLock );
TI_DbgPrint(MID_TRACE,("TCPClose finished %x\n", Status)); TI_DbgPrint(MID_TRACE,("TCPClose finished %x\n", Status));
@ -270,12 +279,14 @@ NTSTATUS TCPListen
Connection = Request->Handle.ConnectionContext; Connection = Request->Handle.ConnectionContext;
ExAcquireFastMutex( &TCPLock );
KeAcquireSpinLock(&Connection->Lock, &OldIrql); KeAcquireSpinLock(&Connection->Lock, &OldIrql);
Status = TCPTranslateError( OskitTCPListen( Connection->SocketContext, Status = TCPTranslateError( OskitTCPListen( Connection->SocketContext,
Backlog ) ); Backlog ) );
KeReleaseSpinLock(&Connection->Lock, OldIrql); KeReleaseSpinLock(&Connection->Lock, OldIrql);
ExReleaseFastMutex( &TCPLock );
return Status; return Status;
} }
@ -303,6 +314,7 @@ NTSTATUS TCPReceiveData
Connection = Request->Handle.ConnectionContext; Connection = Request->Handle.ConnectionContext;
ExAcquireFastMutex( &TCPLock );
KeAcquireSpinLock(&Connection->Lock, &OldIrql); KeAcquireSpinLock(&Connection->Lock, &OldIrql);
NdisQueryBuffer( Buffer, &DataBuffer, &DataLen ); NdisQueryBuffer( Buffer, &DataBuffer, &DataLen );
@ -340,6 +352,7 @@ NTSTATUS TCPReceiveData
} }
KeReleaseSpinLock(&Connection->Lock, OldIrql); KeReleaseSpinLock(&Connection->Lock, OldIrql);
ExReleaseFastMutex( &TCPLock );
TI_DbgPrint(MID_TRACE,("Status %x\n", Status)); TI_DbgPrint(MID_TRACE,("Status %x\n", Status));
@ -360,6 +373,7 @@ NTSTATUS TCPSendData
Connection = Request->Handle.ConnectionContext; Connection = Request->Handle.ConnectionContext;
ExAcquireFastMutex( &TCPLock );
KeAcquireSpinLock(&Connection->Lock, &OldIrql); KeAcquireSpinLock(&Connection->Lock, &OldIrql);
NdisQueryBuffer( Buffer, &BufferData, &PacketSize ); NdisQueryBuffer( Buffer, &BufferData, &PacketSize );
@ -374,6 +388,7 @@ NTSTATUS TCPSendData
BufferData, PacketSize, (PUINT)DataUsed, 0 ); BufferData, PacketSize, (PUINT)DataUsed, 0 );
KeReleaseSpinLock(&Connection->Lock, OldIrql); KeReleaseSpinLock(&Connection->Lock, OldIrql);
ExReleaseFastMutex( &TCPLock );
return Status; return Status;
} }
@ -381,7 +396,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 );
TimerOskitTCP(); TimerOskitTCP();
ExReleaseFastMutex( &TCPLock );
} }
} }