From b47e621749257331788e82e44d1565cf4d32d04b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 30 Apr 2017 13:54:02 -0400 Subject: fix probable race in use of restoreHashes I think there was a race where a SessionKey message had been drained from the TChan, but not yet added to the developer state, which was resonsible for recent instability at startup. It manifested as protocol errors where the prevActivity hash was wrongly Nothing. Fixed by adding a MissingHashes type to tag things whose hashes have been stripped, and adding back the hashes when needed, which always happens inside atomically blocks, so won't have such a race. --- Role/Downloader.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Role/Downloader.hs') diff --git a/Role/Downloader.hs b/Role/Downloader.hs index 094e7de..d013344 100644 --- a/Role/Downloader.hs +++ b/Role/Downloader.hs @@ -14,7 +14,7 @@ import Data.Time.Clock.POSIX run :: DownloadOpts -> IO () run = run' downloader . downloadUrl -downloader :: TMVar (TVar DeveloperState) -> TMChan (Message Entered) -> TMChan AnyMessage -> SessionID -> IO () +downloader :: TMVar (TVar DeveloperState) -> TMChan (Message Entered) -> TMChan (MissingHashes AnyMessage) -> SessionID -> IO () downloader dsv _ichan ochan sid = do let logfile = sessionLogFile "." sid putStrLn $ "Starting download to " ++ logfile -- cgit v1.2.3