fix a deadlock when not using --auto

Live update never gets started, but then it still waited for it to
finish.

This only deadlocked with -J4 or so, not without -J. Unsure why.
This commit is contained in:
Joey Hess 2024-08-27 15:47:57 -04:00
parent b01a63ef62
commit 09955deebe
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -109,7 +109,8 @@ checkLiveUpdate lu a = Db.lockDbWhile (const go) go
finishedLiveUpdate :: LiveUpdate -> UUID -> Key -> SizeChange -> IO ()
finishedLiveUpdate NoLiveUpdate _ _ _ = noop
finishedLiveUpdate lu u k sc = do
finishedLiveUpdate lu u k sc =
whenM (not <$> isEmptyMVar (liveUpdateReady lu)) $ do
finishv <- newEmptyMVar
tryNonAsync (putMVar (liveUpdateDone lu) (Just (u, k, sc, finishv))) >>= \case
Right () -> void $ tryNonAsync $ takeMVar finishv