mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
- TCPIP locking rewrite (part 2 of x)
- Add locking in places that need it - Eliminate double acquisition of TCPLock for the same request - Next step: Verify that all places that need locking have it svn path=/trunk/; revision=41751
This commit is contained in:
parent
e50ff89e86
commit
4c8e421fe9
3 changed files with 20 additions and 35 deletions
|
@ -646,15 +646,19 @@ NTSTATUS DispTdiQueryInformation(
|
|||
PTDI_REQUEST_KERNEL_QUERY_INFORMATION Parameters;
|
||||
PTRANSPORT_CONTEXT TranContext;
|
||||
PIO_STACK_LOCATION IrpSp;
|
||||
NTSTATUS Status;
|
||||
|
||||
TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
|
||||
|
||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||
Parameters = (PTDI_REQUEST_KERNEL_QUERY_INFORMATION)&IrpSp->Parameters;
|
||||
|
||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
||||
|
||||
TranContext = IrpSp->FileObject->FsContext;
|
||||
if (!TranContext) {
|
||||
TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
|
||||
TcpipRecursiveMutexLeave(&TCPLock);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
@ -672,6 +676,7 @@ NTSTATUS DispTdiQueryInformation(
|
|||
(FIELD_OFFSET(TDI_ADDRESS_INFO, Address.Address[0].Address) +
|
||||
sizeof(TDI_ADDRESS_IP))) {
|
||||
TI_DbgPrint(MID_TRACE, ("MDL buffer too small.\n"));
|
||||
TcpipRecursiveMutexLeave(&TCPLock);
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
|
@ -690,6 +695,7 @@ NTSTATUS DispTdiQueryInformation(
|
|||
RtlZeroMemory(
|
||||
&Address->Address[0].Address[0].sin_zero,
|
||||
sizeof(Address->Address[0].Address[0].sin_zero));
|
||||
TcpipRecursiveMutexLeave(&TCPLock);
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
case TDI_CONNECTION_FILE:
|
||||
|
@ -700,18 +706,22 @@ NTSTATUS DispTdiQueryInformation(
|
|||
RtlZeroMemory(
|
||||
&Address->Address[0].Address[0].sin_zero,
|
||||
sizeof(Address->Address[0].Address[0].sin_zero));
|
||||
TcpipRecursiveMutexLeave(&TCPLock);
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
default:
|
||||
TI_DbgPrint(MIN_TRACE, ("Invalid transport context\n"));
|
||||
TcpipRecursiveMutexLeave(&TCPLock);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (!AddrFile) {
|
||||
TI_DbgPrint(MID_TRACE, ("No address file object.\n"));
|
||||
TcpipRecursiveMutexLeave(&TCPLock);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
TcpipRecursiveMutexLeave(&TCPLock);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -725,6 +735,7 @@ NTSTATUS DispTdiQueryInformation(
|
|||
(FIELD_OFFSET(TDI_CONNECTION_INFORMATION, RemoteAddress) +
|
||||
sizeof(PVOID))) {
|
||||
TI_DbgPrint(MID_TRACE, ("MDL buffer too small (ptr).\n"));
|
||||
TcpipRecursiveMutexLeave(&TCPLock);
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
|
@ -743,18 +754,24 @@ NTSTATUS DispTdiQueryInformation(
|
|||
|
||||
default:
|
||||
TI_DbgPrint(MIN_TRACE, ("Invalid transport context\n"));
|
||||
TcpipRecursiveMutexLeave(&TCPLock);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (!Endpoint) {
|
||||
TI_DbgPrint(MID_TRACE, ("No connection object.\n"));
|
||||
TcpipRecursiveMutexLeave(&TCPLock);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
return TCPGetSockAddress( Endpoint, AddressInfo->RemoteAddress, TRUE );
|
||||
Status = TCPGetSockAddress( Endpoint, AddressInfo->RemoteAddress, TRUE );
|
||||
|
||||
TcpipRecursiveMutexLeave(&TCPLock);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
TcpipRecursiveMutexLeave(&TCPLock);
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
|
|
@ -142,6 +142,8 @@ NTSTATUS TCPAccept ( PTDI_REQUEST Request,
|
|||
Status = TCPServiceListeningSocket( Listener, Connection,
|
||||
(PTDI_REQUEST_KERNEL)Request );
|
||||
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
|
||||
if( Status == STATUS_PENDING ) {
|
||||
Bucket = exAllocatePool( NonPagedPool, sizeof(*Bucket) );
|
||||
|
||||
|
@ -155,8 +157,6 @@ NTSTATUS TCPAccept ( PTDI_REQUEST Request,
|
|||
Status = STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,("TCPAccept finished %x\n", Status));
|
||||
return Status;
|
||||
}
|
||||
|
|
|
@ -332,7 +332,6 @@ NTSTATUS TCPSocket( PCONNECTION_ENDPOINT Connection,
|
|||
"Proto %d\n",
|
||||
Connection, Family, Type, Proto));
|
||||
|
||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
||||
Status = TCPTranslateError( OskitTCPSocket( Connection,
|
||||
&Connection->SocketContext,
|
||||
Family,
|
||||
|
@ -344,8 +343,6 @@ NTSTATUS TCPSocket( PCONNECTION_ENDPOINT Connection,
|
|||
TI_DbgPrint(DEBUG_TCP,("Connection->SocketContext %x\n",
|
||||
Connection->SocketContext));
|
||||
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -599,11 +596,8 @@ NTSTATUS TCPConnect
|
|||
return STATUS_NETWORK_UNREACHABLE;
|
||||
}
|
||||
|
||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
||||
|
||||
if (Connection->State & SEL_FIN)
|
||||
{
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
return STATUS_REMOTE_DISCONNECT;
|
||||
}
|
||||
|
||||
|
@ -649,8 +643,6 @@ NTSTATUS TCPConnect
|
|||
}
|
||||
}
|
||||
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -665,8 +657,6 @@ NTSTATUS TCPDisconnect
|
|||
|
||||
TI_DbgPrint(DEBUG_TCP,("started\n"));
|
||||
|
||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
||||
|
||||
switch( Flags & (TDI_DISCONNECT_ABORT | TDI_DISCONNECT_RELEASE) ) {
|
||||
case 0:
|
||||
case TDI_DISCONNECT_ABORT:
|
||||
|
@ -685,8 +675,6 @@ NTSTATUS TCPDisconnect
|
|||
Status = TCPTranslateError
|
||||
( OskitTCPShutdown( Connection->SocketContext, Flags ) );
|
||||
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,("finished %x\n", Status));
|
||||
|
||||
return Status;
|
||||
|
@ -698,16 +686,12 @@ NTSTATUS TCPClose
|
|||
|
||||
TI_DbgPrint(DEBUG_TCP,("TCPClose started\n"));
|
||||
|
||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
||||
|
||||
/* Make our code remove all pending IRPs */
|
||||
Connection->State |= SEL_FIN;
|
||||
DrainSignals();
|
||||
|
||||
Status = TCPTranslateError( OskitTCPClose( Connection->SocketContext ) );
|
||||
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,("TCPClose finished %x\n", Status));
|
||||
|
||||
return Status;
|
||||
|
@ -731,12 +715,9 @@ NTSTATUS TCPReceiveData
|
|||
|
||||
ASSERT_KM_POINTER(Connection->SocketContext);
|
||||
|
||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
||||
|
||||
/* Closing */
|
||||
if (Connection->State & SEL_FIN)
|
||||
{
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
*BytesReceived = 0;
|
||||
return STATUS_REMOTE_DISCONNECT;
|
||||
}
|
||||
|
@ -761,7 +742,6 @@ NTSTATUS TCPReceiveData
|
|||
Bucket = exAllocatePool( NonPagedPool, sizeof(*Bucket) );
|
||||
if( !Bucket ) {
|
||||
TI_DbgPrint(DEBUG_TCP,("Failed to allocate bucket\n"));
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -778,8 +758,6 @@ NTSTATUS TCPReceiveData
|
|||
*BytesReceived = Received;
|
||||
}
|
||||
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,("Status %x\n", Status));
|
||||
|
||||
return Status;
|
||||
|
@ -802,8 +780,6 @@ NTSTATUS TCPSendData
|
|||
|
||||
ASSERT_KM_POINTER(Connection->SocketContext);
|
||||
|
||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,("Connection = %x\n", Connection));
|
||||
TI_DbgPrint(DEBUG_TCP,("Connection->SocketContext = %x\n",
|
||||
Connection->SocketContext));
|
||||
|
@ -811,7 +787,6 @@ NTSTATUS TCPSendData
|
|||
/* Closing */
|
||||
if (Connection->State & SEL_FIN)
|
||||
{
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
*BytesSent = 0;
|
||||
return STATUS_REMOTE_DISCONNECT;
|
||||
}
|
||||
|
@ -829,7 +804,6 @@ NTSTATUS TCPSendData
|
|||
Bucket = exAllocatePool( NonPagedPool, sizeof(*Bucket) );
|
||||
if( !Bucket ) {
|
||||
TI_DbgPrint(DEBUG_TCP,("Failed to allocate bucket\n"));
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -846,8 +820,6 @@ NTSTATUS TCPSendData
|
|||
*BytesSent = Sent;
|
||||
}
|
||||
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,("Status %x\n", Status));
|
||||
|
||||
return Status;
|
||||
|
@ -880,8 +852,6 @@ NTSTATUS TCPGetSockAddress
|
|||
OSK_UI16 LocalPort, RemotePort;
|
||||
PTA_IP_ADDRESS AddressIP = (PTA_IP_ADDRESS)Address;
|
||||
|
||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
||||
|
||||
OskitTCPGetAddress
|
||||
( Connection->SocketContext,
|
||||
&LocalAddress, &LocalPort,
|
||||
|
@ -893,8 +863,6 @@ NTSTATUS TCPGetSockAddress
|
|||
AddressIP->Address[0].Address[0].sin_port = GetRemote ? RemotePort : LocalPort;
|
||||
AddressIP->Address[0].Address[0].in_addr = GetRemote ? RemoteAddress : LocalAddress;
|
||||
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue