From b697c6b9da2471296ceee6fe6d74da28f7567f56 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 22 Jul 2024 15:48:46 -0400 Subject: [PATCH] fix TMVar left full crash affecting servePutOffset Problem is that whatever is reading from the TMVar may not have read from it yet before the client writes the next thing to it. --- P2P/IO.hs | 13 ++----------- doc/todo/git-annex_proxies.mdwn | 3 --- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/P2P/IO.hs b/P2P/IO.hs index 996fdfc2f6..54cea2a224 100644 --- a/P2P/IO.hs +++ b/P2P/IO.hs @@ -195,11 +195,6 @@ runNetProto runst conn = go go (Free (Local _)) = return $ Left $ ProtoFailureMessage "unexpected annex operation attempted" -data P2PTMVarException = P2PTMVarException String - deriving (Show) - -instance Exception P2PTMVarException - -- Interpreter of the Net part of Proto. -- -- An interpreter of Proto has to be provided, to handle the rest of Proto @@ -213,12 +208,8 @@ runNet runst conn runner f = case f of P2PHandle h -> tryNonAsync $ do hPutStrLn h $ unwords (formatMessage m) hFlush h - P2PHandleTMVar mv _ -> - ifM (atomically (tryPutTMVar mv (Right m))) - ( return $ Right () - , return $ Left $ toException $ - P2PTMVarException ("TMVar left full " ++ show m) - ) + P2PHandleTMVar mv _ -> tryNonAsync $ do + atomically $ putTMVar mv (Right m) case v of Left e -> return $ Left $ ProtoFailureException e Right () -> runner next diff --git a/doc/todo/git-annex_proxies.mdwn b/doc/todo/git-annex_proxies.mdwn index aca5bb2eb1..85a2ee0bf2 100644 --- a/doc/todo/git-annex_proxies.mdwn +++ b/doc/todo/git-annex_proxies.mdwn @@ -28,9 +28,6 @@ Planned schedule of work: ## work notes -* servePutOffset crashes with "TMVar left full VALIDITY Invalid". - Seems nothing consumes the INVALID sent by the client, but why? - * Implement serveLockContent * A Locker should expire the lock on its own after 10 minutes initially. -- 2.30.2