diff --git a/drivers/filters/mountmgr/database.c b/drivers/filters/mountmgr/database.c index aa0c6a42ef5..694c98a25fa 100644 --- a/drivers/filters/mountmgr/database.c +++ b/drivers/filters/mountmgr/database.c @@ -1168,21 +1168,40 @@ WorkerThread(IN PDEVICE_OBJECT DeviceObject, NULL, NULL); KeInitializeEvent(&Event, NotificationEvent, FALSE); - Timeout.LowPart = 0xFFFFFFFF; - Timeout.HighPart = 0xFF676980; + Timeout.QuadPart = -10000000LL; /* Wait for 1 second */ - /* Try to wait as long as possible */ - for (i = (Unloading ? 999 : 0); i < 1000; i++) + /* Wait as long as possible for clearance from autochk + * We will write remote databases only if it is safe + * to access volumes. + * First, given we start before SMSS, wait for the + * event creation. + */ + i = 0; + do { - Status = ZwOpenEvent(&SafeEvent, EVENT_ALL_ACCESS, &ObjectAttributes); - if (NT_SUCCESS(Status)) + /* If we started to shutdown, stop waiting forever and jump to last attempt */ + if (Unloading) { - break; + i = 999; + } + else + { + /* Attempt to open the event */ + Status = ZwOpenEvent(&SafeEvent, EVENT_ALL_ACCESS, &ObjectAttributes); + if (NT_SUCCESS(Status)) + { + break; + } + + /* Wait a bit to give SMSS a chance to create the event */ + KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, &Timeout); } - KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, &Timeout); + ++i; } + while (i < 1000); + /* We managed to open the event, wait until autochk signals it */ if (i < 1000) { do @@ -1220,7 +1239,7 @@ WorkerThread(IN PDEVICE_OBJECT DeviceObject, IoFreeWorkItem(WorkItem->WorkItem); FreePool(WorkItem); - if (InterlockedDecrement(&(DeviceExtension->WorkerReferences)) == 0) + if (InterlockedDecrement(&(DeviceExtension->WorkerReferences)) < 0) { return; } @@ -1603,6 +1622,9 @@ ReconcileThisDatabaseWithMaster(IN PDEVICE_EXTENSION DeviceExtension, return; } + UNIMPLEMENTED; + return; + /* Allocate a work item */ WorkItem = AllocatePool(sizeof(RECONCILE_WORK_ITEM)); if (!WorkItem)