fix concurrency

Broken by recent commits, because before dupState is called, the Annex
state needs to have concurrent output enabled, and the thread pool
populated.
This commit is contained in:
Joey Hess 2019-06-19 16:12:39 -04:00
parent 9671248fff
commit a0d3a699e2
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -215,19 +215,20 @@ startConcurrency usedstages a = do
where
goconcurrent n = do
raisecapabilitiesto n
initworkerpool n
withMessageState $ \s -> case outputType s of
NormalOutput -> ifM (liftIO concurrentOutputSupported)
( Regions.displayConsoleRegions $
goconcurrent' True
, goconcurrent' False
goconcurrent' n True
, goconcurrent' n False
)
_ -> goconcurrent' False
goconcurrent' b = bracket_ (setup b) cleanup a
_ -> goconcurrent' n False
goconcurrent' n b = bracket_ (setup n b) cleanup a
goconcurrentpercpu = goconcurrent =<< liftIO getNumProcessors
setup = setconcurrentoutputenabled
setup n b = do
setconcurrentoutputenabled b
initworkerpool n
cleanup = do
finishCommandActions
@ -247,10 +248,11 @@ startConcurrency usedstages a = do
-- could cause threads to contend over eg, calls to
-- setConfig.
_ <- remoteList
st <- dupState
tv <- liftIO $ newTMVarIO $
allocateWorkerPool st (max n 1) usedstages
tv <- liftIO newEmptyTMVarIO
Annex.changeState $ \s -> s { Annex.workers = Just tv }
st <- dupState
liftIO $ atomically $ putTMVar tv $
allocateWorkerPool st (max n 1) usedstages
{- Ensures that only one thread processes a key at a time.
- Other threads will block until it's done.