[MOUNTMGR] Remove cancel routine before completing pending IRP
[reactos.git] / drivers / filters / mountmgr / notify.c
index 8b7c676..9a1e788 100644 (file)
@@ -247,12 +247,14 @@ MountMgrTargetDeviceNotification(IN PVOID NotificationStructure,
      */
     else if (IsEqualGUID(&(Notification->Event), &GUID_IO_VOLUME_MOUNT))
     {
+        /* If we were already mounted, then mark us unmounted */
         if (InterlockedCompareExchange(&(DeviceInformation->MountState),
                                        FALSE,
-                                       TRUE) == TRUE)
+                                       FALSE) == TRUE)
         {
             InterlockedDecrement(&(DeviceInformation->MountState));
         }
+        /* Otherwise, start mounting the device and first, reconcile its DB if required */
         else
         {
             if (DeviceInformation->NeedsReconcile)
@@ -326,6 +328,7 @@ MountMgrNotify(IN PDEVICE_EXTENSION DeviceExtension)
     {
         NextEntry = RemoveHeadList(&(DeviceExtension->IrpListHead));
         Irp = CONTAINING_RECORD(NextEntry, IRP, Tail.Overlay.ListEntry);
+        IoSetCancelRoutine(Irp, NULL);
         InsertTailList(&CopyList, &(Irp->Tail.Overlay.ListEntry));
     }
     IoReleaseCancelSpinLock(OldIrql);