fix TMVar left full crash affecting servePutOffset
authorJoey Hess <joeyh@joeyh.name>
Mon, 22 Jul 2024 19:48:46 +0000 (15:48 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 22 Jul 2024 19:48:46 +0000 (15:48 -0400)
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
doc/todo/git-annex_proxies.mdwn

index 996fdfc2f6295266140517e8064d2ea859376a24..54cea2a224208105d796fa10265911417c72553c 100644 (file)
--- 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
index aca5bb2eb1aef23b96f840edd79263b65b75c391..85a2ee0bf2db44582d0d33370b7924745ad716ea 100644 (file)
@@ -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.