Author: cgutman
Date: Sat Oct 3 23:34:34 2009
New Revision: 43275
URL:
http://svn.reactos.org/svn/reactos?rev=43275&view=rev
Log:
- Add cancellation support for IOCTL_AFD_SELECT
- Fix release build
Modified:
trunk/reactos/drivers/network/afd/afd/main.c
trunk/reactos/drivers/network/afd/afd/select.c
trunk/reactos/drivers/network/afd/include/afd.h
Modified: trunk/reactos/drivers/network/afd/afd/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/ma…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/main.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/main.c [iso-8859-1] Sat Oct 3 23:34:34 2009
@@ -517,6 +517,10 @@
PAFD_SEND_INFO SendReq;
PLIST_ENTRY CurrentEntry;
PIRP CurrentIrp;
+ PAFD_DEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension;
+ KIRQL OldIrql;
+ PAFD_ACTIVE_POLL Poll;
+ PAFD_POLL_INFO PollReq;
IoReleaseCancelSpinLock(Irp->CancelIrql);
@@ -553,9 +557,38 @@
Function = FUNCTION_PREACCEPT;
break;
+ case IOCTL_AFD_SELECT:
+ KeAcquireSpinLock(&DeviceExt->Lock, &OldIrql);
+
+ CurrentEntry = DeviceExt->Polls.Flink;
+ while (CurrentEntry != &DeviceExt->Polls)
+ {
+ Poll = CONTAINING_RECORD(CurrentEntry, AFD_ACTIVE_POLL, ListEntry);
+ CurrentIrp = Poll->Irp;
+ PollReq = CurrentIrp->AssociatedIrp.SystemBuffer;
+
+ if (CurrentIrp == Irp)
+ {
+ ZeroEvents(PollReq->Handles, PollReq->HandleCount);
+ SignalSocket(Poll, NULL, PollReq, STATUS_CANCELLED);
+ break;
+ }
+ else
+ {
+ CurrentEntry = CurrentEntry->Flink;
+ }
+ }
+
+ KeReleaseSpinLock(&DeviceExt->Lock, OldIrql);
+
+ /* IRP already completed by SignalSocket */
+ SocketStateUnlock(FCB);
+ return;
+
default:
ASSERT(FALSE);
- break;
+ UnlockAndMaybeComplete(FCB, STATUS_CANCELLED, Irp, 0);
+ return;
}
CurrentEntry = FCB->PendingIrpList[Function].Flink;
Modified: trunk/reactos/drivers/network/afd/afd/select.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/se…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/select.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/select.c [iso-8859-1] Sat Oct 3 23:34:34 2009
@@ -43,7 +43,7 @@
}
}
-static VOID ZeroEvents( PAFD_HANDLE HandleArray,
+VOID ZeroEvents( PAFD_HANDLE HandleArray,
UINT HandleCount ) {
UINT i;
@@ -55,7 +55,7 @@
/* you must pass either Poll OR Irp */
-static VOID SignalSocket(
+VOID SignalSocket(
PAFD_ACTIVE_POLL Poll OPTIONAL,
PIRP _Irp OPTIONAL,
PAFD_POLL_INFO PollReq,
@@ -89,6 +89,7 @@
UnlockHandles( AFD_HANDLES(PollReq), PollReq->HandleCount );
if( Irp->MdlAddress ) UnlockRequest( Irp, IoGetCurrentIrpStackLocation( Irp ) );
AFD_DbgPrint(MID_TRACE,("Completing\n"));
+ (void)IoSetCancelRoutine(Irp, NULL);
IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
AFD_DbgPrint(MID_TRACE,("Done\n"));
}
@@ -244,6 +245,7 @@
Status = STATUS_PENDING;
IoMarkIrpPending( Irp );
+ (void)IoSetCancelRoutine(Irp, AfdCancelHandler);
} else {
AFD_DbgPrint(MAX_TRACE, ("FIXME: do something with the IRP!\n"));
Status = STATUS_NO_MEMORY;
Modified: trunk/reactos/drivers/network/afd/include/afd.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/includ…
==============================================================================
--- trunk/reactos/drivers/network/afd/include/afd.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/include/afd.h [iso-8859-1] Sat Oct 3 23:34:34 2009
@@ -315,6 +315,11 @@
VOID PollReeval( PAFD_DEVICE_EXTENSION DeviceObject, PFILE_OBJECT FileObject );
VOID KillSelectsForFCB( PAFD_DEVICE_EXTENSION DeviceExt,
PFILE_OBJECT FileObject, BOOLEAN ExclusiveOnly );
+VOID ZeroEvents( PAFD_HANDLE HandleArray,
+ UINT HandleCount );
+VOID SignalSocket(
+ PAFD_ACTIVE_POLL Poll OPTIONAL, PIRP _Irp OPTIONAL,
+ PAFD_POLL_INFO PollReq, NTSTATUS Status);
/* tdi.c */