avoid interleaving command stages with Concurrency 1
authorJoey Hess <joeyh@joeyh.name>
Wed, 16 Sep 2020 16:10:45 +0000 (12:10 -0400)
committerJoey Hess <joeyh@joeyh.name>
Wed, 16 Sep 2020 16:10:45 +0000 (12:10 -0400)
Before, -J1 was different than no -J: It makes concurrent-output be used
for display, and it actually can run concurrent jobs in some situations.
Eg, a perform stage and a cleanup stage can both run.

dupState is used in several places, and changes NonConcurrent to
Concurrent 1. My concern is that this might, in some case, enable
that concurrent behavior. And in particular, that it might get enabled in
--batch mode, when the user is not expecting concurrent output because
they did not pass -J.

While I don't have a test case where that happens and causes out of
order output, it looks like it could, and so prudent to make this change.

CmdLine/Action.hs

index 591c590b9af17020cf86e4251b91c0333d7c0677..03a664fd6c2fde029efffaa5bff94015be57b4b0 100644 (file)
@@ -55,7 +55,9 @@ commandActions = mapM_ commandAction
 commandAction :: CommandStart -> Annex ()
 commandAction start = getConcurrency >>= \case
        NonConcurrent -> runnonconcurrent
-       Concurrent _ -> runconcurrent
+       Concurrent n
+               | n > 1 -> runconcurrent
+               | otherwise -> runnonconcurrent
        ConcurrentPerCpu -> runconcurrent
   where
        runnonconcurrent = void $ includeCommandAction start