mirror of https://github.com/voidlizard/hbs2
fixing stucked garbage problem
This commit is contained in:
parent
91a2563134
commit
8374fb5a3a
|
@ -54,24 +54,25 @@ ncqStateUpdateLoop ncq@NCQStorage{..} = do
|
||||||
|
|
||||||
debug $ red "ncqStateUpdateLoop"
|
debug $ red "ncqStateUpdateLoop"
|
||||||
|
|
||||||
|
ncqStateDump ncq
|
||||||
|
|
||||||
sInit <- readTVarIO ncqState
|
sInit <- readTVarIO ncqState <&> ncqStateVersion
|
||||||
|
|
||||||
flip fix sInit $ \next s0 -> do
|
flip fix sInit $ \next s0 -> do
|
||||||
state <- atomically do
|
state <- atomically do
|
||||||
s1 <- readTVar ncqState
|
s1 <- readTVar ncqState <&> ncqStateVersion
|
||||||
stop <- readTVar ncqStopReq
|
stop <- readTVar ncqStopReq
|
||||||
dump <- readTVar ncqStateDumpReq
|
dump <- readTVar ncqStateDumpReq
|
||||||
if s1 == s0 && not stop && not dump then STM.retry else pure s1
|
if s1 == s0 && not stop && not dump then STM.retry else pure s1
|
||||||
|
|
||||||
key <- ncqStateDump ncq
|
ncqStateDump ncq
|
||||||
|
|
||||||
done <- atomically do
|
done <- atomically do
|
||||||
modifyTVar ncqWrites succ
|
modifyTVar ncqWrites succ
|
||||||
readTVar ncqStopReq
|
readTVar ncqStopReq
|
||||||
|
|
||||||
unless done do
|
unless done do
|
||||||
next =<< readTVarIO ncqState
|
next state
|
||||||
|
|
||||||
ncqStateUpdate :: MonadIO m
|
ncqStateUpdate :: MonadIO m
|
||||||
=> NCQStorage
|
=> NCQStorage
|
||||||
|
|
Loading…
Reference in New Issue