VOID NTAPI CmpLazyFlushWorker(IN PVOID Parameter) { BOOLEAN ForceFlush, Result, MoreWork = FALSE; ULONG DirtyCount = 0; PAGED_CODE(); /* Don't do anything if lazy flushing isn't enabled yet */ if (CmpHoldLazyFlush) { DPRINT1("Lazy flush held. Bye bye.\n"); CmpLazyFlushPending = FALSE; return; } /* Check if we are forcing a flush */ ForceFlush = CmpForceForceFlush; if (ForceFlush) { DPRINT("Forcing flush.\n"); /* Lock the registry exclusively */ CmpLockRegistryExclusive(); } else { DPRINT("Not forcing flush.\n"); /* Starve writers before locking */ InterlockedIncrement(&CmpFlushStarveWriters); CmpLockRegistry(); } /* Flush the next hive */ MoreWork = CmpDoFlushNextHive(ForceFlush, &Result, &DirtyCount); if (!MoreWork) { /* We're done */ InterlockedIncrement((PLONG)&CmpLazyFlushCount); } /* Check if we have starved writers */ if (!ForceFlush) InterlockedDecrement(&CmpFlushStarveWriters); /* Not pending anymore, release the registry lock */ CmpLazyFlushPending = FALSE; CmpUnlockRegistry(); DPRINT("Lazy flush done. More work to be done: %s. Entries still dirty: %u.\n", MoreWork ? "Yes" : "No", DirtyCount); if (MoreWork) { /* Relaunch the flush timer, so the remaining hives get flushed */ CmpLazyFlush(); } }
VOID NTAPI CmpLazyFlushWorker(IN PVOID Parameter) { BOOLEAN ForceFlush, Result, MoreWork = FALSE; ULONG DirtyCount = 0; PAGED_CODE(); /* Don't do anything if lazy flushing isn't enabled yet */ if (CmpHoldLazyFlush) return; /* Check if we are forcing a flush */ ForceFlush = CmpForceForceFlush; if (ForceFlush) { /* Lock the registry exclusively */ CmpLockRegistryExclusive(); } else { /* Do a normal lock */ CmpLockRegistry(); InterlockedIncrement(&CmpFlushStarveWriters); } /* Flush the next hive */ MoreWork = CmpDoFlushNextHive(ForceFlush, &Result, &DirtyCount); if (!MoreWork) { /* We're done */ InterlockedIncrement((PLONG)&CmpLazyFlushCount); } /* Check if we have starved writers */ if (!ForceFlush) InterlockedDecrement(&CmpFlushStarveWriters); /* Not pending anymore, release the registry lock */ CmpLazyFlushPending = FALSE; CmpUnlockRegistry(); /* Check if we need to flush another hive */ if ((MoreWork) || (DirtyCount)) CmpLazyFlush(); }