fix restoring worker pool bug

The bug might have led to a STM deadlock, if this case could ever
actually fire.
This commit is contained in:
Joey Hess 2019-06-17 12:51:44 -04:00
parent 1a8d06d251
commit ecbd456312
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -193,11 +193,12 @@ changeStageTo newstage = do
liftIO $ atomically $ waitWorkerSlot' (== newstage) tv >>= \case
Just idlest -> do
pool <- takeTMVar tv
let restorepool = addWorkerPool (IdleWorker idlest newstage) pool
let pool' = case removeThreadIdWorkerPool mytid pool of
Just ((myaid, oldstage), p) ->
addWorkerPool (IdleWorker idlest oldstage) $
addWorkerPool (ActiveWorker myaid newstage) p
Nothing -> pool
Nothing -> restorepool
putTMVar tv pool'
-- No worker pool is allocated, not running in concurrent
-- mode.