Skip to content
Snippets Groups Projects
Commit deca6e7b authored by Robert's avatar Robert Committed by mergify-bot
Browse files

Replace use of 'withAsync' by 'concurrently', to not lose exceptions

This fixes deadlock in asyncFetchPackages:

  withAsync action1 (\_ -> action2)

loses exceptions thrown by action1. If in addition, action2
has a dependency on data produced by action1 (as is the case
here), this will block indefinitely.

(This bug caused some of the new tests to hang, since after
the change to use async-safe try, it became easier for
fetchPackages to throw an exception.)
parent d0b268ea
No related branches found
No related tags found
No related merge requests found
...@@ -252,13 +252,15 @@ asyncFetchPackages verbosity repoCtxt pkglocs body = do ...@@ -252,13 +252,15 @@ asyncFetchPackages verbosity repoCtxt pkglocs body = do
-- Suppress marking here, because 'withAsync' means -- Suppress marking here, because 'withAsync' means
-- that we get nondeterministic interleaving. -- that we get nondeterministic interleaving.
-- It is essential that we don't catch async exceptions here, -- It is essential that we don't catch async exceptions here,
-- specifically AsyncCancelled thrown at us from withAsync. -- specifically 'AsyncCancelled' thrown at us from 'concurrently'.
result <- Safe.try $ result <- Safe.try $
fetchPackage (verboseUnmarkOutput verbosity) repoCtxt pkgloc fetchPackage (verboseUnmarkOutput verbosity) repoCtxt pkgloc
putMVar var result putMVar var result
withAsync fetchPackages $ \_ -> (_, res) <- concurrently
body (Map.fromList asyncDownloadVars) fetchPackages
(body $ Map.fromList asyncDownloadVars)
pure res
-- | Expect to find a download in progress in the given 'AsyncFetchMap' -- | Expect to find a download in progress in the given 'AsyncFetchMap'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment