mirror of
https://github.com/reactos/reactos.git
synced 2025-04-27 09:00:27 +00:00
- Stop using the TCPLock to protect all entries into the IP lib
- Instead use TCPLock only to protect entries into oskittcp svn path=/trunk/; revision=44021
This commit is contained in:
parent
4983e19cca
commit
024d413ccb
8 changed files with 51 additions and 77 deletions
|
@ -13,8 +13,7 @@ extern VOID TcpipInterlockedInsertTailList( PLIST_ENTRY ListHead,
|
||||||
extern VOID TcpipAcquireFastMutex( PFAST_MUTEX Mutex );
|
extern VOID TcpipAcquireFastMutex( PFAST_MUTEX Mutex );
|
||||||
extern VOID TcpipReleaseFastMutex( PFAST_MUTEX Mutex );
|
extern VOID TcpipReleaseFastMutex( PFAST_MUTEX Mutex );
|
||||||
extern VOID TcpipRecursiveMutexInit( PRECURSIVE_MUTEX RecMutex );
|
extern VOID TcpipRecursiveMutexInit( PRECURSIVE_MUTEX RecMutex );
|
||||||
extern VOID TcpipRecursiveMutexEnter( PRECURSIVE_MUTEX RecMutex,
|
extern VOID TcpipRecursiveMutexEnter( PRECURSIVE_MUTEX RecMutex );
|
||||||
BOOLEAN ToWrite );
|
|
||||||
extern VOID TcpipRecursiveMutexLeave( PRECURSIVE_MUTEX RecMutex );
|
extern VOID TcpipRecursiveMutexLeave( PRECURSIVE_MUTEX RecMutex );
|
||||||
|
|
||||||
#endif/*_LOCK_H*/
|
#endif/*_LOCK_H*/
|
||||||
|
|
|
@ -352,8 +352,6 @@ NTSTATUS DispTdiConnect(
|
||||||
|
|
||||||
/* Get associated connection endpoint file object. Quit if none exists */
|
/* Get associated connection endpoint file object. Quit if none exists */
|
||||||
|
|
||||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
|
||||||
|
|
||||||
TranContext = IrpSp->FileObject->FsContext;
|
TranContext = IrpSp->FileObject->FsContext;
|
||||||
if (!TranContext) {
|
if (!TranContext) {
|
||||||
TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
|
TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
|
||||||
|
@ -384,8 +382,6 @@ NTSTATUS DispTdiConnect(
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
TcpipRecursiveMutexLeave( &TCPLock );
|
|
||||||
|
|
||||||
if (Status != STATUS_PENDING) {
|
if (Status != STATUS_PENDING) {
|
||||||
DispDataRequestComplete(Irp, Status, 0);
|
DispDataRequestComplete(Irp, Status, 0);
|
||||||
} else
|
} else
|
||||||
|
@ -465,8 +461,6 @@ NTSTATUS DispTdiDisconnect(
|
||||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||||
DisReq = (PTDI_REQUEST_KERNEL_DISCONNECT)&IrpSp->Parameters;
|
DisReq = (PTDI_REQUEST_KERNEL_DISCONNECT)&IrpSp->Parameters;
|
||||||
|
|
||||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
|
||||||
|
|
||||||
/* Get associated connection endpoint file object. Quit if none exists */
|
/* Get associated connection endpoint file object. Quit if none exists */
|
||||||
|
|
||||||
TranContext = IrpSp->FileObject->FsContext;
|
TranContext = IrpSp->FileObject->FsContext;
|
||||||
|
@ -492,8 +486,6 @@ NTSTATUS DispTdiDisconnect(
|
||||||
Irp );
|
Irp );
|
||||||
|
|
||||||
done:
|
done:
|
||||||
TcpipRecursiveMutexLeave( &TCPLock );
|
|
||||||
|
|
||||||
if (Status != STATUS_PENDING) {
|
if (Status != STATUS_PENDING) {
|
||||||
DispDataRequestComplete(Irp, Status, 0);
|
DispDataRequestComplete(Irp, Status, 0);
|
||||||
} else
|
} else
|
||||||
|
@ -527,8 +519,6 @@ NTSTATUS DispTdiListen(
|
||||||
|
|
||||||
/* Get associated connection endpoint file object. Quit if none exists */
|
/* Get associated connection endpoint file object. Quit if none exists */
|
||||||
|
|
||||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
|
||||||
|
|
||||||
TranContext = IrpSp->FileObject->FsContext;
|
TranContext = IrpSp->FileObject->FsContext;
|
||||||
if (TranContext == NULL)
|
if (TranContext == NULL)
|
||||||
{
|
{
|
||||||
|
@ -593,8 +583,6 @@ NTSTATUS DispTdiListen(
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
TcpipRecursiveMutexLeave( &TCPLock );
|
|
||||||
|
|
||||||
if (Status != STATUS_PENDING) {
|
if (Status != STATUS_PENDING) {
|
||||||
DispDataRequestComplete(Irp, Status, 0);
|
DispDataRequestComplete(Irp, Status, 0);
|
||||||
} else
|
} else
|
||||||
|
@ -621,19 +609,15 @@ NTSTATUS DispTdiQueryInformation(
|
||||||
PTDI_REQUEST_KERNEL_QUERY_INFORMATION Parameters;
|
PTDI_REQUEST_KERNEL_QUERY_INFORMATION Parameters;
|
||||||
PTRANSPORT_CONTEXT TranContext;
|
PTRANSPORT_CONTEXT TranContext;
|
||||||
PIO_STACK_LOCATION IrpSp;
|
PIO_STACK_LOCATION IrpSp;
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
|
TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
|
||||||
|
|
||||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||||
Parameters = (PTDI_REQUEST_KERNEL_QUERY_INFORMATION)&IrpSp->Parameters;
|
Parameters = (PTDI_REQUEST_KERNEL_QUERY_INFORMATION)&IrpSp->Parameters;
|
||||||
|
|
||||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
|
||||||
|
|
||||||
TranContext = IrpSp->FileObject->FsContext;
|
TranContext = IrpSp->FileObject->FsContext;
|
||||||
if (!TranContext) {
|
if (!TranContext) {
|
||||||
TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
|
TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
|
||||||
TcpipRecursiveMutexLeave(&TCPLock);
|
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,7 +635,6 @@ NTSTATUS DispTdiQueryInformation(
|
||||||
(FIELD_OFFSET(TDI_ADDRESS_INFO, Address.Address[0].Address) +
|
(FIELD_OFFSET(TDI_ADDRESS_INFO, Address.Address[0].Address) +
|
||||||
sizeof(TDI_ADDRESS_IP))) {
|
sizeof(TDI_ADDRESS_IP))) {
|
||||||
TI_DbgPrint(MID_TRACE, ("MDL buffer too small.\n"));
|
TI_DbgPrint(MID_TRACE, ("MDL buffer too small.\n"));
|
||||||
TcpipRecursiveMutexLeave(&TCPLock);
|
|
||||||
return STATUS_BUFFER_TOO_SMALL;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -670,7 +653,6 @@ NTSTATUS DispTdiQueryInformation(
|
||||||
RtlZeroMemory(
|
RtlZeroMemory(
|
||||||
&Address->Address[0].Address[0].sin_zero,
|
&Address->Address[0].Address[0].sin_zero,
|
||||||
sizeof(Address->Address[0].Address[0].sin_zero));
|
sizeof(Address->Address[0].Address[0].sin_zero));
|
||||||
TcpipRecursiveMutexLeave(&TCPLock);
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|
||||||
case TDI_CONNECTION_FILE:
|
case TDI_CONNECTION_FILE:
|
||||||
|
@ -681,12 +663,10 @@ NTSTATUS DispTdiQueryInformation(
|
||||||
RtlZeroMemory(
|
RtlZeroMemory(
|
||||||
&Address->Address[0].Address[0].sin_zero,
|
&Address->Address[0].Address[0].sin_zero,
|
||||||
sizeof(Address->Address[0].Address[0].sin_zero));
|
sizeof(Address->Address[0].Address[0].sin_zero));
|
||||||
TcpipRecursiveMutexLeave(&TCPLock);
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
TI_DbgPrint(MIN_TRACE, ("Invalid transport context\n"));
|
TI_DbgPrint(MIN_TRACE, ("Invalid transport context\n"));
|
||||||
TcpipRecursiveMutexLeave(&TCPLock);
|
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -701,7 +681,6 @@ NTSTATUS DispTdiQueryInformation(
|
||||||
(FIELD_OFFSET(TDI_CONNECTION_INFORMATION, RemoteAddress) +
|
(FIELD_OFFSET(TDI_CONNECTION_INFORMATION, RemoteAddress) +
|
||||||
sizeof(PVOID))) {
|
sizeof(PVOID))) {
|
||||||
TI_DbgPrint(MID_TRACE, ("MDL buffer too small (ptr).\n"));
|
TI_DbgPrint(MID_TRACE, ("MDL buffer too small (ptr).\n"));
|
||||||
TcpipRecursiveMutexLeave(&TCPLock);
|
|
||||||
return STATUS_BUFFER_TOO_SMALL;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -721,24 +700,18 @@ NTSTATUS DispTdiQueryInformation(
|
||||||
|
|
||||||
default:
|
default:
|
||||||
TI_DbgPrint(MIN_TRACE, ("Invalid transport context\n"));
|
TI_DbgPrint(MIN_TRACE, ("Invalid transport context\n"));
|
||||||
TcpipRecursiveMutexLeave(&TCPLock);
|
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Endpoint) {
|
if (!Endpoint) {
|
||||||
TI_DbgPrint(MID_TRACE, ("No connection object.\n"));
|
TI_DbgPrint(MID_TRACE, ("No connection object.\n"));
|
||||||
TcpipRecursiveMutexLeave(&TCPLock);
|
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = TCPGetSockAddress( Endpoint, AddressInfo->RemoteAddress, TRUE );
|
return TCPGetSockAddress( Endpoint, AddressInfo->RemoteAddress, TRUE );
|
||||||
|
|
||||||
TcpipRecursiveMutexLeave(&TCPLock);
|
|
||||||
return Status;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TcpipRecursiveMutexLeave(&TCPLock);
|
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -764,8 +737,6 @@ NTSTATUS DispTdiReceive(
|
||||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||||
ReceiveInfo = (PTDI_REQUEST_KERNEL_RECEIVE)&(IrpSp->Parameters);
|
ReceiveInfo = (PTDI_REQUEST_KERNEL_RECEIVE)&(IrpSp->Parameters);
|
||||||
|
|
||||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
|
||||||
|
|
||||||
TranContext = IrpSp->FileObject->FsContext;
|
TranContext = IrpSp->FileObject->FsContext;
|
||||||
if (TranContext == NULL)
|
if (TranContext == NULL)
|
||||||
{
|
{
|
||||||
|
@ -801,8 +772,6 @@ NTSTATUS DispTdiReceive(
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
TcpipRecursiveMutexLeave( &TCPLock );
|
|
||||||
|
|
||||||
if (Status != STATUS_PENDING) {
|
if (Status != STATUS_PENDING) {
|
||||||
DispDataRequestComplete(Irp, Status, BytesReceived);
|
DispDataRequestComplete(Irp, Status, BytesReceived);
|
||||||
} else
|
} else
|
||||||
|
@ -836,8 +805,6 @@ NTSTATUS DispTdiReceiveDatagram(
|
||||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||||
DgramInfo = (PTDI_REQUEST_KERNEL_RECEIVEDG)&(IrpSp->Parameters);
|
DgramInfo = (PTDI_REQUEST_KERNEL_RECEIVEDG)&(IrpSp->Parameters);
|
||||||
|
|
||||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
|
||||||
|
|
||||||
TranContext = IrpSp->FileObject->FsContext;
|
TranContext = IrpSp->FileObject->FsContext;
|
||||||
if (TranContext == NULL)
|
if (TranContext == NULL)
|
||||||
{
|
{
|
||||||
|
@ -879,8 +846,6 @@ NTSTATUS DispTdiReceiveDatagram(
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
TcpipRecursiveMutexLeave( &TCPLock );
|
|
||||||
|
|
||||||
if (Status != STATUS_PENDING) {
|
if (Status != STATUS_PENDING) {
|
||||||
DispDataRequestComplete(Irp, Status, BytesReceived);
|
DispDataRequestComplete(Irp, Status, BytesReceived);
|
||||||
} else
|
} else
|
||||||
|
@ -913,8 +878,6 @@ NTSTATUS DispTdiSend(
|
||||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||||
SendInfo = (PTDI_REQUEST_KERNEL_SEND)&(IrpSp->Parameters);
|
SendInfo = (PTDI_REQUEST_KERNEL_SEND)&(IrpSp->Parameters);
|
||||||
|
|
||||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
|
||||||
|
|
||||||
TranContext = IrpSp->FileObject->FsContext;
|
TranContext = IrpSp->FileObject->FsContext;
|
||||||
if (TranContext == NULL)
|
if (TranContext == NULL)
|
||||||
{
|
{
|
||||||
|
@ -955,8 +918,6 @@ NTSTATUS DispTdiSend(
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
TcpipRecursiveMutexLeave( &TCPLock );
|
|
||||||
|
|
||||||
if (Status != STATUS_PENDING) {
|
if (Status != STATUS_PENDING) {
|
||||||
DispDataRequestComplete(Irp, Status, BytesSent);
|
DispDataRequestComplete(Irp, Status, BytesSent);
|
||||||
} else
|
} else
|
||||||
|
@ -989,8 +950,6 @@ NTSTATUS DispTdiSendDatagram(
|
||||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||||
DgramInfo = (PTDI_REQUEST_KERNEL_SENDDG)&(IrpSp->Parameters);
|
DgramInfo = (PTDI_REQUEST_KERNEL_SENDDG)&(IrpSp->Parameters);
|
||||||
|
|
||||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
|
||||||
|
|
||||||
TranContext = IrpSp->FileObject->FsContext;
|
TranContext = IrpSp->FileObject->FsContext;
|
||||||
if (TranContext == NULL)
|
if (TranContext == NULL)
|
||||||
{
|
{
|
||||||
|
@ -1037,8 +996,6 @@ NTSTATUS DispTdiSendDatagram(
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
TcpipRecursiveMutexLeave( &TCPLock );
|
|
||||||
|
|
||||||
if (Status != STATUS_PENDING) {
|
if (Status != STATUS_PENDING) {
|
||||||
DispDataRequestComplete(Irp, Status, Irp->IoStatus.Information);
|
DispDataRequestComplete(Irp, Status, Irp->IoStatus.Information);
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -382,9 +382,7 @@ NTSTATUS FileCloseAddress(
|
||||||
case IPPROTO_TCP:
|
case IPPROTO_TCP:
|
||||||
TCPFreePort( AddrFile->Port );
|
TCPFreePort( AddrFile->Port );
|
||||||
if( AddrFile->Listener ) {
|
if( AddrFile->Listener ) {
|
||||||
TcpipRecursiveMutexEnter(&TCPLock, TRUE);
|
|
||||||
TCPClose( AddrFile->Listener );
|
TCPClose( AddrFile->Listener );
|
||||||
TcpipRecursiveMutexLeave(&TCPLock);
|
|
||||||
exFreePool( AddrFile->Listener );
|
exFreePool( AddrFile->Listener );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -425,9 +423,7 @@ NTSTATUS FileOpenConnection(
|
||||||
|
|
||||||
if( !Connection ) return STATUS_NO_MEMORY;
|
if( !Connection ) return STATUS_NO_MEMORY;
|
||||||
|
|
||||||
TcpipRecursiveMutexEnter(&TCPLock, TRUE);
|
|
||||||
Status = TCPSocket( Connection, AF_INET, SOCK_STREAM, IPPROTO_TCP );
|
Status = TCPSocket( Connection, AF_INET, SOCK_STREAM, IPPROTO_TCP );
|
||||||
TcpipRecursiveMutexLeave(&TCPLock);
|
|
||||||
|
|
||||||
if( !NT_SUCCESS(Status) ) {
|
if( !NT_SUCCESS(Status) ) {
|
||||||
TCPFreeConnectionEndpoint( Connection );
|
TCPFreeConnectionEndpoint( Connection );
|
||||||
|
@ -500,9 +496,7 @@ NTSTATUS FileCloseConnection(
|
||||||
RemoveEntryList(&Connection->ListEntry);
|
RemoveEntryList(&Connection->ListEntry);
|
||||||
TcpipReleaseSpinLock(&ConnectionEndpointListLock, OldIrql);
|
TcpipReleaseSpinLock(&ConnectionEndpointListLock, OldIrql);
|
||||||
|
|
||||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
|
||||||
TCPClose( Connection );
|
TCPClose( Connection );
|
||||||
TcpipRecursiveMutexLeave( &TCPLock );
|
|
||||||
|
|
||||||
TCPFreeConnectionEndpoint(Connection);
|
TCPFreeConnectionEndpoint(Connection);
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ VOID TcpipRecursiveMutexInit( PRECURSIVE_MUTEX RecMutex ) {
|
||||||
RecursiveMutexInit( RecMutex );
|
RecursiveMutexInit( RecMutex );
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID TcpipRecursiveMutexEnter( PRECURSIVE_MUTEX RecMutex, BOOLEAN ToWrite ) {
|
VOID TcpipRecursiveMutexEnter( PRECURSIVE_MUTEX RecMutex ) {
|
||||||
//TI_DbgPrint(DEBUG_LOCK,("Locking\n"));
|
//TI_DbgPrint(DEBUG_LOCK,("Locking\n"));
|
||||||
RecursiveMutexEnter( RecMutex );
|
RecursiveMutexEnter( RecMutex );
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,8 +48,7 @@ VOID TcpipReleaseFastMutex( PFAST_MUTEX Mutex ) {
|
||||||
VOID TcpipRecursiveMutexInit( PRECURSIVE_MUTEX RecMutex ) {
|
VOID TcpipRecursiveMutexInit( PRECURSIVE_MUTEX RecMutex ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT TcpipRecursiveMutexEnter( PRECURSIVE_MUTEX RecMutex, BOOL ToWrite ) {
|
VOID TcpipRecursiveMutexEnter( PRECURSIVE_MUTEX RecMutex ) {
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID TcpipRecursiveMutexLeave( PRECURSIVE_MUTEX RecMutex ) {
|
VOID TcpipRecursiveMutexLeave( PRECURSIVE_MUTEX RecMutex ) {
|
||||||
|
|
|
@ -19,8 +19,6 @@ NTSTATUS TCPServiceListeningSocket( PCONNECTION_ENDPOINT Listener,
|
||||||
PTA_IP_ADDRESS RequestAddressReturn;
|
PTA_IP_ADDRESS RequestAddressReturn;
|
||||||
PTDI_CONNECTION_INFORMATION WhoIsConnecting;
|
PTDI_CONNECTION_INFORMATION WhoIsConnecting;
|
||||||
|
|
||||||
ASSERT_LOCKED(&TCPLock);
|
|
||||||
|
|
||||||
/* Unpack TDI info -- We need the return connection information
|
/* Unpack TDI info -- We need the return connection information
|
||||||
* struct to return the address so it can be filtered if needed
|
* struct to return the address so it can be filtered if needed
|
||||||
* by WSAAccept -- The returned address will be passed on to
|
* by WSAAccept -- The returned address will be passed on to
|
||||||
|
@ -28,6 +26,8 @@ NTSTATUS TCPServiceListeningSocket( PCONNECTION_ENDPOINT Listener,
|
||||||
WhoIsConnecting = (PTDI_CONNECTION_INFORMATION)
|
WhoIsConnecting = (PTDI_CONNECTION_INFORMATION)
|
||||||
Request->ReturnConnectionInformation;
|
Request->ReturnConnectionInformation;
|
||||||
|
|
||||||
|
TcpipRecursiveMutexEnter(&TCPLock);
|
||||||
|
|
||||||
Status = TCPTranslateError
|
Status = TCPTranslateError
|
||||||
( OskitTCPAccept( Listener->SocketContext,
|
( OskitTCPAccept( Listener->SocketContext,
|
||||||
&Connection->SocketContext,
|
&Connection->SocketContext,
|
||||||
|
@ -36,6 +36,8 @@ NTSTATUS TCPServiceListeningSocket( PCONNECTION_ENDPOINT Listener,
|
||||||
&OutAddrLen,
|
&OutAddrLen,
|
||||||
Request->RequestFlags & TDI_QUERY_ACCEPT ? 0 : 1 ) );
|
Request->RequestFlags & TDI_QUERY_ACCEPT ? 0 : 1 ) );
|
||||||
|
|
||||||
|
TcpipRecursiveMutexLeave(&TCPLock);
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_TCP,("Status %x\n", Status));
|
TI_DbgPrint(DEBUG_TCP,("Status %x\n", Status));
|
||||||
|
|
||||||
if( NT_SUCCESS(Status) && Status != STATUS_PENDING ) {
|
if( NT_SUCCESS(Status) && Status != STATUS_PENDING ) {
|
||||||
|
@ -70,8 +72,6 @@ NTSTATUS TCPListen( PCONNECTION_ENDPOINT Connection, UINT Backlog ) {
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
SOCKADDR_IN AddressToBind;
|
SOCKADDR_IN AddressToBind;
|
||||||
|
|
||||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
|
||||||
|
|
||||||
ASSERT(Connection);
|
ASSERT(Connection);
|
||||||
ASSERT_KM_POINTER(Connection->SocketContext);
|
ASSERT_KM_POINTER(Connection->SocketContext);
|
||||||
ASSERT_KM_POINTER(Connection->AddressFile);
|
ASSERT_KM_POINTER(Connection->AddressFile);
|
||||||
|
@ -89,6 +89,8 @@ NTSTATUS TCPListen( PCONNECTION_ENDPOINT Connection, UINT Backlog ) {
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_TCP,("AddressToBind - %x:%x\n", AddressToBind.sin_addr, AddressToBind.sin_port));
|
TI_DbgPrint(DEBUG_TCP,("AddressToBind - %x:%x\n", AddressToBind.sin_addr, AddressToBind.sin_port));
|
||||||
|
|
||||||
|
TcpipRecursiveMutexEnter( &TCPLock );
|
||||||
|
|
||||||
Status = TCPTranslateError( OskitTCPBind( Connection->SocketContext,
|
Status = TCPTranslateError( OskitTCPBind( Connection->SocketContext,
|
||||||
&AddressToBind,
|
&AddressToBind,
|
||||||
sizeof(AddressToBind) ) );
|
sizeof(AddressToBind) ) );
|
||||||
|
@ -138,13 +140,9 @@ NTSTATUS TCPAccept ( PTDI_REQUEST Request,
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_TCP,("TCPAccept started\n"));
|
TI_DbgPrint(DEBUG_TCP,("TCPAccept started\n"));
|
||||||
|
|
||||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
|
||||||
|
|
||||||
Status = TCPServiceListeningSocket( Listener, Connection,
|
Status = TCPServiceListeningSocket( Listener, Connection,
|
||||||
(PTDI_REQUEST_KERNEL)Request );
|
(PTDI_REQUEST_KERNEL)Request );
|
||||||
|
|
||||||
TcpipRecursiveMutexLeave( &TCPLock );
|
|
||||||
|
|
||||||
if( Status == STATUS_PENDING ) {
|
if( Status == STATUS_PENDING ) {
|
||||||
Bucket = exAllocatePool( NonPagedPool, sizeof(*Bucket) );
|
Bucket = exAllocatePool( NonPagedPool, sizeof(*Bucket) );
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,16 @@ int TCPSocketState(void *ClientData,
|
||||||
|
|
||||||
Connection->SignalState |= NewState;
|
Connection->SignalState |= NewState;
|
||||||
|
|
||||||
|
TcpipRecursiveMutexLeave(&TCPLock);
|
||||||
|
|
||||||
|
/* We must not be locked when handling signalled connections
|
||||||
|
* because a completion could trigger another IOCTL which
|
||||||
|
* would cause a deadlock
|
||||||
|
*/
|
||||||
NewState = HandleSignalledConnection(Connection);
|
NewState = HandleSignalledConnection(Connection);
|
||||||
|
|
||||||
|
TcpipRecursiveMutexEnter(&TCPLock);
|
||||||
|
|
||||||
KeAcquireSpinLock(&SignalledConnectionsLock, &OldIrql);
|
KeAcquireSpinLock(&SignalledConnectionsLock, &OldIrql);
|
||||||
if ((NewState == 0 || NewState == SEL_FIN) &&
|
if ((NewState == 0 || NewState == SEL_FIN) &&
|
||||||
(OldState != 0 && OldState != SEL_FIN))
|
(OldState != 0 && OldState != SEL_FIN))
|
||||||
|
|
|
@ -28,8 +28,6 @@ ULONG HandleSignalledConnection( PCONNECTION_ENDPOINT Connection ) {
|
||||||
PIRP Irp;
|
PIRP Irp;
|
||||||
PMDL Mdl;
|
PMDL Mdl;
|
||||||
|
|
||||||
ASSERT_LOCKED(&TCPLock);
|
|
||||||
|
|
||||||
TI_DbgPrint(MID_TRACE,("Handling signalled state on %x (%x)\n",
|
TI_DbgPrint(MID_TRACE,("Handling signalled state on %x (%x)\n",
|
||||||
Connection, Connection->SocketContext));
|
Connection, Connection->SocketContext));
|
||||||
|
|
||||||
|
@ -337,7 +335,7 @@ NTSTATUS TCPSocket( PCONNECTION_ENDPOINT Connection,
|
||||||
UINT Family, UINT Type, UINT Proto ) {
|
UINT Family, UINT Type, UINT Proto ) {
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
ASSERT_LOCKED(&TCPLock);
|
TcpipRecursiveMutexEnter(&TCPLock);
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_TCP,("Called: Connection %x, Family %d, Type %d, "
|
TI_DbgPrint(DEBUG_TCP,("Called: Connection %x, Family %d, Type %d, "
|
||||||
"Proto %d\n",
|
"Proto %d\n",
|
||||||
|
@ -354,6 +352,8 @@ NTSTATUS TCPSocket( PCONNECTION_ENDPOINT Connection,
|
||||||
TI_DbgPrint(DEBUG_TCP,("Connection->SocketContext %x\n",
|
TI_DbgPrint(DEBUG_TCP,("Connection->SocketContext %x\n",
|
||||||
Connection->SocketContext));
|
Connection->SocketContext));
|
||||||
|
|
||||||
|
TcpipRecursiveMutexLeave(&TCPLock);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,7 +370,7 @@ VOID TCPReceive(PIP_INTERFACE Interface, PIP_PACKET IPPacket)
|
||||||
IPPacket->TotalSize,
|
IPPacket->TotalSize,
|
||||||
IPPacket->HeaderSize));
|
IPPacket->HeaderSize));
|
||||||
|
|
||||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
TcpipRecursiveMutexEnter( &TCPLock );
|
||||||
|
|
||||||
OskitTCPReceiveDatagram( IPPacket->Header,
|
OskitTCPReceiveDatagram( IPPacket->Header,
|
||||||
IPPacket->TotalSize,
|
IPPacket->TotalSize,
|
||||||
|
@ -447,12 +447,13 @@ TimerThread(PVOID Context)
|
||||||
PsTerminateSystemThread(Status);
|
PsTerminateSystemThread(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
TcpipRecursiveMutexEnter( &TCPLock );
|
||||||
TimerOskitTCP( Next == NextFast, Next == NextSlow );
|
TimerOskitTCP( Next == NextFast, Next == NextSlow );
|
||||||
|
TcpipRecursiveMutexLeave( &TCPLock );
|
||||||
|
|
||||||
if (Next == NextSlow) {
|
if (Next == NextSlow) {
|
||||||
DrainSignals();
|
DrainSignals();
|
||||||
}
|
}
|
||||||
TcpipRecursiveMutexLeave( &TCPLock );
|
|
||||||
|
|
||||||
Current = Next;
|
Current = Next;
|
||||||
if (10 <= Current) {
|
if (10 <= Current) {
|
||||||
|
@ -496,7 +497,7 @@ NTSTATUS TCPStartup(VOID)
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
TcpipRecursiveMutexEnter(&TCPLock, TRUE);
|
TcpipRecursiveMutexEnter(&TCPLock);
|
||||||
RegisterOskitTCPEventHandlers( &EventHandlers );
|
RegisterOskitTCPEventHandlers( &EventHandlers );
|
||||||
InitOskitTCP();
|
InitOskitTCP();
|
||||||
TcpipRecursiveMutexLeave(&TCPLock);
|
TcpipRecursiveMutexLeave(&TCPLock);
|
||||||
|
@ -544,7 +545,9 @@ NTSTATUS TCPShutdown(VOID)
|
||||||
|
|
||||||
TCPInitialized = FALSE;
|
TCPInitialized = FALSE;
|
||||||
|
|
||||||
|
TcpipRecursiveMutexEnter(&TCPLock);
|
||||||
DeinitOskitTCP();
|
DeinitOskitTCP();
|
||||||
|
TcpipRecursiveMutexLeave(&TCPLock);
|
||||||
|
|
||||||
PortsShutdown( &TCPPorts );
|
PortsShutdown( &TCPPorts );
|
||||||
|
|
||||||
|
@ -597,8 +600,6 @@ NTSTATUS TCPConnect
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_TCP,("TCPConnect: Called\n"));
|
TI_DbgPrint(DEBUG_TCP,("TCPConnect: Called\n"));
|
||||||
|
|
||||||
ASSERT_LOCKED(&TCPLock);
|
|
||||||
|
|
||||||
Status = AddrBuildAddress
|
Status = AddrBuildAddress
|
||||||
((PTRANSPORT_ADDRESS)ConnInfo->RemoteAddress,
|
((PTRANSPORT_ADDRESS)ConnInfo->RemoteAddress,
|
||||||
&RemoteAddress,
|
&RemoteAddress,
|
||||||
|
@ -624,6 +625,8 @@ NTSTATUS TCPConnect
|
||||||
AddressToBind = AddressToConnect;
|
AddressToBind = AddressToConnect;
|
||||||
AddressToBind.sin_addr.s_addr = NCE->Interface->Unicast.Address.IPv4Address;
|
AddressToBind.sin_addr.s_addr = NCE->Interface->Unicast.Address.IPv4Address;
|
||||||
|
|
||||||
|
TcpipRecursiveMutexEnter(&TCPLock);
|
||||||
|
|
||||||
Status = TCPTranslateError
|
Status = TCPTranslateError
|
||||||
( OskitTCPBind( Connection->SocketContext,
|
( OskitTCPBind( Connection->SocketContext,
|
||||||
&AddressToBind,
|
&AddressToBind,
|
||||||
|
@ -655,6 +658,8 @@ NTSTATUS TCPConnect
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TcpipRecursiveMutexLeave(&TCPLock);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,12 +676,16 @@ NTSTATUS TCPDisconnect
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_TCP,("started\n"));
|
TI_DbgPrint(DEBUG_TCP,("started\n"));
|
||||||
|
|
||||||
|
TcpipRecursiveMutexEnter(&TCPLock);
|
||||||
|
|
||||||
if (Flags & TDI_DISCONNECT_RELEASE)
|
if (Flags & TDI_DISCONNECT_RELEASE)
|
||||||
Status = TCPTranslateError(OskitTCPDisconnect(Connection->SocketContext));
|
Status = TCPTranslateError(OskitTCPDisconnect(Connection->SocketContext));
|
||||||
|
|
||||||
if ((Flags & TDI_DISCONNECT_ABORT) || !Flags)
|
if ((Flags & TDI_DISCONNECT_ABORT) || !Flags)
|
||||||
Status = TCPTranslateError(OskitTCPShutdown(Connection->SocketContext, FWRITE | FREAD));
|
Status = TCPTranslateError(OskitTCPShutdown(Connection->SocketContext, FWRITE | FREAD));
|
||||||
|
|
||||||
|
TcpipRecursiveMutexLeave(&TCPLock);
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_TCP,("finished %x\n", Status));
|
TI_DbgPrint(DEBUG_TCP,("finished %x\n", Status));
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -688,16 +697,18 @@ NTSTATUS TCPClose
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_TCP,("TCPClose started\n"));
|
TI_DbgPrint(DEBUG_TCP,("TCPClose started\n"));
|
||||||
|
|
||||||
ASSERT_LOCKED(&TCPLock);
|
|
||||||
|
|
||||||
/* Make our code remove all pending IRPs */
|
/* Make our code remove all pending IRPs */
|
||||||
Connection->SignalState |= SEL_FIN;
|
Connection->SignalState |= SEL_FIN;
|
||||||
HandleSignalledConnection(Connection);
|
HandleSignalledConnection(Connection);
|
||||||
|
|
||||||
|
TcpipRecursiveMutexEnter(&TCPLock);
|
||||||
|
|
||||||
Status = TCPTranslateError( OskitTCPClose( Connection->SocketContext ) );
|
Status = TCPTranslateError( OskitTCPClose( Connection->SocketContext ) );
|
||||||
if (Status == STATUS_SUCCESS)
|
if (Status == STATUS_SUCCESS)
|
||||||
Connection->SocketContext = NULL;
|
Connection->SocketContext = NULL;
|
||||||
|
|
||||||
|
TcpipRecursiveMutexLeave(&TCPLock);
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_TCP,("TCPClose finished %x\n", Status));
|
TI_DbgPrint(DEBUG_TCP,("TCPClose finished %x\n", Status));
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -719,14 +730,14 @@ NTSTATUS TCPReceiveData
|
||||||
TI_DbgPrint(DEBUG_TCP,("Called for %d bytes (on socket %x)\n",
|
TI_DbgPrint(DEBUG_TCP,("Called for %d bytes (on socket %x)\n",
|
||||||
ReceiveLength, Connection->SocketContext));
|
ReceiveLength, Connection->SocketContext));
|
||||||
|
|
||||||
ASSERT_LOCKED(&TCPLock);
|
|
||||||
|
|
||||||
ASSERT_KM_POINTER(Connection->SocketContext);
|
ASSERT_KM_POINTER(Connection->SocketContext);
|
||||||
|
|
||||||
NdisQueryBuffer( Buffer, &DataBuffer, &DataLen );
|
NdisQueryBuffer( Buffer, &DataBuffer, &DataLen );
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_TCP,("TCP>|< Got an MDL %x (%x:%d)\n", Buffer, DataBuffer, DataLen));
|
TI_DbgPrint(DEBUG_TCP,("TCP>|< Got an MDL %x (%x:%d)\n", Buffer, DataBuffer, DataLen));
|
||||||
|
|
||||||
|
TcpipRecursiveMutexEnter(&TCPLock);
|
||||||
|
|
||||||
Status = TCPTranslateError
|
Status = TCPTranslateError
|
||||||
( OskitTCPRecv
|
( OskitTCPRecv
|
||||||
( Connection->SocketContext,
|
( Connection->SocketContext,
|
||||||
|
@ -735,6 +746,8 @@ NTSTATUS TCPReceiveData
|
||||||
&Received,
|
&Received,
|
||||||
ReceiveFlags ) );
|
ReceiveFlags ) );
|
||||||
|
|
||||||
|
TcpipRecursiveMutexLeave(&TCPLock);
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_TCP,("OskitTCPReceive: %x, %d\n", Status, Received));
|
TI_DbgPrint(DEBUG_TCP,("OskitTCPReceive: %x, %d\n", Status, Received));
|
||||||
|
|
||||||
/* Keep this request around ... there was no data yet */
|
/* Keep this request around ... there was no data yet */
|
||||||
|
@ -787,12 +800,15 @@ NTSTATUS TCPSendData
|
||||||
TI_DbgPrint(DEBUG_TCP,("Connection->SocketContext = %x\n",
|
TI_DbgPrint(DEBUG_TCP,("Connection->SocketContext = %x\n",
|
||||||
Connection->SocketContext));
|
Connection->SocketContext));
|
||||||
|
|
||||||
|
TcpipRecursiveMutexEnter(&TCPLock);
|
||||||
|
|
||||||
Status = TCPTranslateError
|
Status = TCPTranslateError
|
||||||
( OskitTCPSend( Connection->SocketContext,
|
( OskitTCPSend( Connection->SocketContext,
|
||||||
(OSK_PCHAR)BufferData, SendLength,
|
(OSK_PCHAR)BufferData, SendLength,
|
||||||
&Sent, 0 ) );
|
&Sent, 0 ) );
|
||||||
|
|
||||||
|
TcpipRecursiveMutexLeave(&TCPLock);
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_TCP,("OskitTCPSend: %x, %d\n", Status, Sent));
|
TI_DbgPrint(DEBUG_TCP,("OskitTCPSend: %x, %d\n", Status, Sent));
|
||||||
|
|
||||||
/* Keep this request around ... there was no data yet */
|
/* Keep this request around ... there was no data yet */
|
||||||
|
@ -850,11 +866,14 @@ NTSTATUS TCPGetSockAddress
|
||||||
PTA_IP_ADDRESS AddressIP = (PTA_IP_ADDRESS)Address;
|
PTA_IP_ADDRESS AddressIP = (PTA_IP_ADDRESS)Address;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
ASSERT_LOCKED(&TCPLock);
|
TcpipRecursiveMutexEnter(&TCPLock);
|
||||||
|
|
||||||
Status = TCPTranslateError(OskitTCPGetAddress(Connection->SocketContext,
|
Status = TCPTranslateError(OskitTCPGetAddress(Connection->SocketContext,
|
||||||
&LocalAddress, &LocalPort,
|
&LocalAddress, &LocalPort,
|
||||||
&RemoteAddress, &RemotePort));
|
&RemoteAddress, &RemotePort));
|
||||||
|
|
||||||
|
TcpipRecursiveMutexLeave(&TCPLock);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
return Status;
|
return Status;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue