Author: cgutman
Date: Fri Oct 7 05:52:52 2011
New Revision: 54042
URL:
http://svn.reactos.org/svn/reactos?rev=54042&view=rev
Log:
[KBDCLASS/MOUCLASS]
- Better fix for the race condition
Modified:
trunk/reactos/drivers/input/kbdclass/kbdclass.c
trunk/reactos/drivers/input/mouclass/mouclass.c
Modified: trunk/reactos/drivers/input/kbdclass/kbdclass.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/input/kbdclass/kbd…
==============================================================================
--- trunk/reactos/drivers/input/kbdclass/kbdclass.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/input/kbdclass/kbdclass.c [iso-8859-1] Fri Oct 7 05:52:52 2011
@@ -761,6 +761,7 @@
{
PCLASS_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
NTSTATUS Status;
+ KIRQL OldIrql;
TRACE_(CLASS_NAME, "HandleReadIrp(DeviceObject %p, Irp %p)\n", DeviceObject,
Irp);
@@ -804,18 +805,20 @@
}
else
{
- IoMarkIrpPending(Irp);
- DeviceExtension->PendingIrp = Irp;
- (VOID)IoSetCancelRoutine(Irp, ClassCancelRoutine);
- if (Irp->Cancel && IoSetCancelRoutine(Irp, NULL))
+ IoAcquireCancelSpinLock(&OldIrql);
+ if (Irp->Cancel)
{
DeviceExtension->PendingIrp = NULL;
Status = STATUS_CANCELLED;
}
else
{
+ IoMarkIrpPending(Irp);
+ DeviceExtension->PendingIrp = Irp;
+ (VOID)IoSetCancelRoutine(Irp, ClassCancelRoutine);
Status = STATUS_PENDING;
}
+ IoReleaseCancelSpinLock(OldIrql);
}
return Status;
}
Modified: trunk/reactos/drivers/input/mouclass/mouclass.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/input/mouclass/mou…
==============================================================================
--- trunk/reactos/drivers/input/mouclass/mouclass.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/input/mouclass/mouclass.c [iso-8859-1] Fri Oct 7 05:52:52 2011
@@ -738,6 +738,7 @@
{
PCLASS_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
NTSTATUS Status;
+ KIRQL OldIrql;
TRACE_(CLASS_NAME, "HandleReadIrp(DeviceObject %p, Irp %p)\n", DeviceObject,
Irp);
@@ -781,18 +782,20 @@
}
else
{
- IoMarkIrpPending(Irp);
- DeviceExtension->PendingIrp = Irp;
- (VOID)IoSetCancelRoutine(Irp, ClassCancelRoutine);
- if (Irp->Cancel && IoSetCancelRoutine(Irp, NULL))
+ IoAcquireCancelSpinLock(&OldIrql);
+ if (Irp->Cancel)
{
DeviceExtension->PendingIrp = NULL;
Status = STATUS_CANCELLED;
}
else
{
+ IoMarkIrpPending(Irp);
+ DeviceExtension->PendingIrp = Irp;
+ (VOID)IoSetCancelRoutine(Irp, ClassCancelRoutine);
Status = STATUS_PENDING;
}
+ IoReleaseCancelSpinLock(OldIrql);
}
return Status;
}