fixing stucked garbage problem

This commit is contained in:
voidlizard 2025-08-24 09:01:21 +03:00
parent 91a2563134
commit 8374fb5a3a
1 changed files with 5 additions and 4 deletions

View File

@ -54,24 +54,25 @@ ncqStateUpdateLoop ncq@NCQStorage{..} = do
debug $ red "ncqStateUpdateLoop"
ncqStateDump ncq
sInit <- readTVarIO ncqState
sInit <- readTVarIO ncqState <&> ncqStateVersion
flip fix sInit $ \next s0 -> do
state <- atomically do
s1 <- readTVar ncqState
s1 <- readTVar ncqState <&> ncqStateVersion
stop <- readTVar ncqStopReq
dump <- readTVar ncqStateDumpReq
if s1 == s0 && not stop && not dump then STM.retry else pure s1
key <- ncqStateDump ncq
ncqStateDump ncq
done <- atomically do
modifyTVar ncqWrites succ
readTVar ncqStopReq
unless done do
next =<< readTVarIO ncqState
next state
ncqStateUpdate :: MonadIO m
=> NCQStorage