mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Fixes: Lock does not need to acquire a spinlock in the non-passive-level
case because we can't contend with outselves in passive level. Realized subtle bug in select. Select needs a referenced file object rather than a handle. Will change this when i get time. svn path=/trunk/; revision=10993
This commit is contained in:
parent
36cc9bb181
commit
51580f3182
5 changed files with 39 additions and 37 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: lock.c,v 1.2 2004/07/18 22:49:17 arty Exp $
|
||||
/* $Id: lock.c,v 1.3 2004/09/23 06:42:16 arty Exp $
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: drivers/net/afd/afd/lock.c
|
||||
|
@ -100,6 +100,7 @@ VOID UnlockBuffers( PAFD_WSABUF Buf, UINT Count ) {
|
|||
UINT SocketAcquireStateLock( PAFD_FCB FCB ) {
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
PVOID CurrentThread = KeGetCurrentThread();
|
||||
KIRQL CurrentIrql = KeGetCurrentIrql();
|
||||
|
||||
AFD_DbgPrint(MAX_TRACE,("Called on %x, attempting to lock\n", FCB));
|
||||
|
||||
|
@ -120,7 +121,8 @@ UINT SocketAcquireStateLock( PAFD_FCB FCB ) {
|
|||
CurrentThread, FCB->CurrentThread));
|
||||
}
|
||||
|
||||
if( KeGetCurrentIrql() == PASSIVE_LEVEL ) {
|
||||
|
||||
if( CurrentIrql == PASSIVE_LEVEL ) {
|
||||
ExAcquireFastMutex( &FCB->Mutex );
|
||||
while( FCB->Locked ) {
|
||||
AFD_DbgPrint
|
||||
|
@ -139,8 +141,7 @@ UINT SocketAcquireStateLock( PAFD_FCB FCB ) {
|
|||
FCB->CurrentThread = CurrentThread;
|
||||
FCB->LockCount++;
|
||||
ExReleaseFastMutex( &FCB->Mutex );
|
||||
} else {
|
||||
KeAcquireSpinLock( &FCB->SpinLock, &FCB->OldIrql );
|
||||
} else { /* Nothing since we're not at PASSIVE_LEVEL */
|
||||
FCB->Locked = TRUE;
|
||||
FCB->CurrentThread = CurrentThread;
|
||||
FCB->LockCount++;
|
||||
|
@ -156,14 +157,7 @@ VOID SocketStateUnlock( PAFD_FCB FCB ) {
|
|||
|
||||
if( !FCB->LockCount ) {
|
||||
FCB->CurrentThread = NULL;
|
||||
if( KeGetCurrentIrql() == PASSIVE_LEVEL ) {
|
||||
ExAcquireFastMutex( &FCB->Mutex );
|
||||
FCB->Locked = FALSE;
|
||||
ExReleaseFastMutex( &FCB->Mutex );
|
||||
} else {
|
||||
FCB->Locked = FALSE;
|
||||
KeReleaseSpinLock( &FCB->SpinLock, FCB->OldIrql );
|
||||
}
|
||||
FCB->Locked = FALSE;
|
||||
|
||||
AFD_DbgPrint(MAX_TRACE,("Unlocked.\n"));
|
||||
KePulseEvent( &FCB->StateLockedEvent, IO_NETWORK_INCREMENT, FALSE );
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: main.c,v 1.6 2004/09/05 04:26:29 arty Exp $
|
||||
/* $Id: main.c,v 1.7 2004/09/23 06:42:16 arty Exp $
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: drivers/net/afd/afd/main.c
|
||||
|
@ -139,7 +139,6 @@ AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
VOID DestroySocket( PAFD_FCB FCB ) {
|
||||
UINT i;
|
||||
PAFD_IN_FLIGHT_REQUEST InFlightRequest[IN_FLIGHT_REQUESTS];
|
||||
BOOLEAN DontDeleteYet = FALSE;
|
||||
|
||||
AFD_DbgPrint(MIN_TRACE,("Called (%x)\n", FCB));
|
||||
|
||||
|
@ -151,6 +150,7 @@ VOID DestroySocket( PAFD_FCB FCB ) {
|
|||
InFlightRequest[1] = &FCB->ReceiveIrp;
|
||||
InFlightRequest[2] = &FCB->SendIrp;
|
||||
|
||||
/* Return early here because we might be called in the mean time. */
|
||||
if( FCB->ListenIrp.InFlightRequest ||
|
||||
FCB->ReceiveIrp.InFlightRequest ||
|
||||
FCB->SendIrp.InFlightRequest ) {
|
||||
|
@ -158,7 +158,8 @@ VOID DestroySocket( PAFD_FCB FCB ) {
|
|||
FCB->ListenIrp.InFlightRequest,
|
||||
FCB->ReceiveIrp.InFlightRequest,
|
||||
FCB->SendIrp.InFlightRequest));
|
||||
DontDeleteYet = TRUE;
|
||||
SocketStateUnlock( FCB );
|
||||
return;
|
||||
}
|
||||
|
||||
FCB->PollState |= AFD_EVENT_CLOSE;
|
||||
|
@ -180,21 +181,19 @@ VOID DestroySocket( PAFD_FCB FCB ) {
|
|||
|
||||
SocketStateUnlock( FCB );
|
||||
|
||||
if( !DontDeleteYet ) {
|
||||
if( FCB->Recv.Window )
|
||||
ExFreePool( FCB->Recv.Window );
|
||||
if( FCB->Send.Window )
|
||||
ExFreePool( FCB->Send.Window );
|
||||
if( FCB->AddressFrom )
|
||||
ExFreePool( FCB->AddressFrom );
|
||||
if( FCB->LocalAddress )
|
||||
ExFreePool( FCB->LocalAddress );
|
||||
|
||||
ExFreePool(FCB->TdiDeviceName.Buffer);
|
||||
|
||||
ExFreePool(FCB);
|
||||
AFD_DbgPrint(MIN_TRACE,("Deleted (%x)\n", FCB));
|
||||
}
|
||||
if( FCB->Recv.Window )
|
||||
ExFreePool( FCB->Recv.Window );
|
||||
if( FCB->Send.Window )
|
||||
ExFreePool( FCB->Send.Window );
|
||||
if( FCB->AddressFrom )
|
||||
ExFreePool( FCB->AddressFrom );
|
||||
if( FCB->LocalAddress )
|
||||
ExFreePool( FCB->LocalAddress );
|
||||
|
||||
ExFreePool(FCB->TdiDeviceName.Buffer);
|
||||
|
||||
ExFreePool(FCB);
|
||||
AFD_DbgPrint(MIN_TRACE,("Deleted (%x)\n", FCB));
|
||||
|
||||
AFD_DbgPrint(MIN_TRACE,("Leaving\n"));
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: select.c,v 1.3 2004/09/05 04:26:29 arty Exp $
|
||||
/* $Id: select.c,v 1.4 2004/09/23 06:42:16 arty Exp $
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: drivers/net/afd/afd/select.c
|
||||
|
@ -58,11 +58,13 @@ ScanForImmediateTrigger( PAFD_HANDLE HandleArray,
|
|||
/* Check select bits */
|
||||
if( !SocketAcquireStateLock( FCB ) )
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
if( NT_SUCCESS(Status) )
|
||||
if( NT_SUCCESS(Status) ) {
|
||||
HandleArray[i].Status =
|
||||
FCB->PollState & HandleArray[i].Events;
|
||||
if( HandleArray[i].Status ) ShouldReturnNow = TRUE;
|
||||
ObDereferenceObject( (PVOID)HandleArray[i].Handle );
|
||||
if( HandleArray[i].Status ) ShouldReturnNow = TRUE;
|
||||
ObDereferenceObject( (PVOID)HandleArray[i].Handle );
|
||||
SocketStateUnlock( FCB );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1024,7 +1024,7 @@ NTSTATUS TdiSendDatagram(
|
|||
* TransportObject = Pointer to transport object
|
||||
* From = Send filter (NULL if none)
|
||||
* Address = Address of buffer to place remote address
|
||||
* Buffer = Address of buffer to place sendd data
|
||||
* Buffer = Address of buffer to place send data
|
||||
* BufferSize = Address of buffer with length of Buffer (updated)
|
||||
* RETURNS:
|
||||
* Status of operation
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: write.c,v 1.5 2004/09/05 04:26:29 arty Exp $
|
||||
/* $Id: write.c,v 1.6 2004/09/23 06:42:16 arty Exp $
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: drivers/net/afd/afd/write.c
|
||||
|
@ -285,7 +285,14 @@ AfdPacketSocketWriteData(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
if( !(SendReq = LockRequest( Irp, IrpSp )) )
|
||||
return UnlockAndMaybeComplete
|
||||
( FCB, STATUS_NO_MEMORY, Irp, 0, NULL, FALSE );
|
||||
|
||||
|
||||
AFD_DbgPrint
|
||||
(MID_TRACE,("RemoteAddress #%d Type %d\n",
|
||||
((PTRANSPORT_ADDRESS)SendReq->RemoteAddress)->
|
||||
TAAddressCount,
|
||||
((PTRANSPORT_ADDRESS)SendReq->RemoteAddress)->
|
||||
Address[0].AddressType));
|
||||
|
||||
/* Check the size of the Address given ... */
|
||||
|
||||
Status = TdiSendDatagram
|
||||
|
|
Loading…
Reference in a new issue