From 09955deebeeb0f285c6aba46ba434059ac8d788e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 27 Aug 2024 15:47:57 -0400 Subject: [PATCH] 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. --- Annex/RepoSize/LiveUpdate.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Annex/RepoSize/LiveUpdate.hs b/Annex/RepoSize/LiveUpdate.hs index 17dae1dec7..aaacb31450 100644 --- a/Annex/RepoSize/LiveUpdate.hs +++ b/Annex/RepoSize/LiveUpdate.hs @@ -109,8 +109,9 @@ checkLiveUpdate lu a = Db.lockDbWhile (const go) go finishedLiveUpdate :: LiveUpdate -> UUID -> Key -> SizeChange -> IO () finishedLiveUpdate NoLiveUpdate _ _ _ = noop -finishedLiveUpdate lu u k sc = do - finishv <- newEmptyMVar - tryNonAsync (putMVar (liveUpdateDone lu) (Just (u, k, sc, finishv))) >>= \case - Right () -> void $ tryNonAsync $ takeMVar finishv - Left _ -> noop +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 + Left _ -> noop