Author: cgutman
Date: Tue Sep 9 23:59:12 2008
New Revision: 36102
URL:
http://svn.reactos.org/svn/reactos?rev=36102&view=rev
Log:
- Don't call IoCompleteRequest while holding a spin lock because it can cause
deadlocks
Modified:
branches/aicom-network-fixes/drivers/network/afd/afd/select.c
Modified: branches/aicom-network-fixes/drivers/network/afd/afd/select.c
URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/drivers/net…
==============================================================================
--- branches/aicom-network-fixes/drivers/network/afd/afd/select.c [iso-8859-1] (original)
+++ branches/aicom-network-fixes/drivers/network/afd/afd/select.c [iso-8859-1] Tue Sep 9
23:59:12 2008
@@ -86,8 +86,6 @@
}
UnlockHandles( AFD_HANDLES(PollReq), PollReq->HandleCount );
if( Irp->MdlAddress ) UnlockRequest( Irp, IoGetCurrentIrpStackLocation( Irp ) );
- AFD_DbgPrint(MID_TRACE,("Completing\n"));
- IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
AFD_DbgPrint(MID_TRACE,("Done\n"));
}
@@ -112,6 +110,8 @@
KeAcquireSpinLock( &DeviceExt->Lock, &OldIrql );
SignalSocket( Poll, NULL, PollReq, STATUS_TIMEOUT );
KeReleaseSpinLock( &DeviceExt->Lock, OldIrql );
+
+ IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
AFD_DbgPrint(MID_TRACE,("Timeout\n"));
}
@@ -146,6 +146,9 @@
(!OnlyExclusive || (OnlyExclusive && Poll->Exclusive)) ) {
ZeroEvents( PollReq->Handles, PollReq->HandleCount );
SignalSocket( Poll, NULL, PollReq, STATUS_SUCCESS );
+ KeReleaseSpinLock( &DeviceExt->Lock, OldIrql );
+ IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
+ KeAcquireSpinLock( &DeviceExt->Lock, &OldIrql );
}
}
}
@@ -230,6 +233,9 @@
Status = STATUS_SUCCESS;
Irp->IoStatus.Status = Status;
SignalSocket( NULL, Irp, PollReq, Status );
+ KeReleaseSpinLock( &DeviceExt->Lock, OldIrql );
+ IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
+ return Status;
} else {
PAFD_ACTIVE_POLL Poll = NULL;
@@ -383,6 +389,7 @@
KIRQL OldIrql;
PAFD_POLL_INFO PollReq;
PKEVENT EventSelect = NULL;
+ PIRP Irp;
AFD_DbgPrint(MID_TRACE,("Called: DeviceExt %x FileObject %x\n",
DeviceExt, FileObject));
@@ -412,13 +419,17 @@
while( ThePollEnt != &DeviceExt->Polls ) {
Poll = CONTAINING_RECORD( ThePollEnt, AFD_ACTIVE_POLL, ListEntry );
- PollReq = Poll->Irp->AssociatedIrp.SystemBuffer;
+ Irp = Poll->Irp;
+ PollReq = Irp->AssociatedIrp.SystemBuffer;
AFD_DbgPrint(MID_TRACE,("Checking poll %x\n", Poll));
if( UpdatePollWithFCB( Poll, FileObject ) ) {
ThePollEnt = ThePollEnt->Flink;
AFD_DbgPrint(MID_TRACE,("Signalling socket\n"));
SignalSocket( Poll, NULL, PollReq, STATUS_SUCCESS );
+ KeReleaseSpinLock( &DeviceExt->Lock, OldIrql );
+ IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
+ KeAcquireSpinLock( &DeviceExt->Lock, &OldIrql );
} else
ThePollEnt = ThePollEnt->Flink;
}