mirror of
https://github.com/reactos/reactos.git
synced 2024-11-20 06:15:26 +00:00
[MOUNTMGR] Fix invalid WorkerReferences check in QueueWorkItem()
This fixes shutting down ReactOS under certain circumstances, where the references were incremented, but no worker thread started. Also, took the opportunity to clarify the WorkerReferences comparisons where relevant. CORE-16446
This commit is contained in:
parent
c8cbd566f9
commit
457612702b
2 changed files with 4 additions and 4 deletions
|
@ -1268,8 +1268,8 @@ QueueWorkItem(IN PDEVICE_EXTENSION DeviceExtension,
|
|||
|
||||
/* When called, lock is already acquired */
|
||||
|
||||
/* If noone, start to work */
|
||||
if (InterlockedIncrement(&(DeviceExtension->WorkerReferences)))
|
||||
/* If noone (-1 as references), start to work */
|
||||
if (InterlockedIncrement(&(DeviceExtension->WorkerReferences)) == 0)
|
||||
{
|
||||
IoQueueWorkItem(WorkItem->WorkItem, WorkerThread, DelayedWorkQueue, DeviceExtension);
|
||||
}
|
||||
|
|
|
@ -822,7 +822,7 @@ MountMgrUnload(IN struct _DRIVER_OBJECT *DriverObject)
|
|||
KeInitializeEvent(&UnloadEvent, NotificationEvent, FALSE);
|
||||
|
||||
/* Wait for workers to finish */
|
||||
if (InterlockedIncrement(&DeviceExtension->WorkerReferences))
|
||||
if (InterlockedIncrement(&DeviceExtension->WorkerReferences) > 0)
|
||||
{
|
||||
KeReleaseSemaphore(&(DeviceExtension->WorkerSemaphore),
|
||||
IO_NO_INCREMENT, 1, FALSE);
|
||||
|
@ -1770,7 +1770,7 @@ MountMgrShutdown(IN PDEVICE_OBJECT DeviceObject,
|
|||
KeInitializeEvent(&UnloadEvent, NotificationEvent, FALSE);
|
||||
|
||||
/* Wait for workers */
|
||||
if (InterlockedIncrement(&(DeviceExtension->WorkerReferences)))
|
||||
if (InterlockedIncrement(&(DeviceExtension->WorkerReferences)) > 0)
|
||||
{
|
||||
KeReleaseSemaphore(&(DeviceExtension->WorkerSemaphore),
|
||||
IO_NO_INCREMENT,
|
||||
|
|
Loading…
Reference in a new issue