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.
This commit is contained in:
Joey Hess 2024-07-22 15:48:46 -04:00
parent 3069e28dd8
commit b697c6b9da
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 2 additions and 14 deletions

View file

@ -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

View 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.