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:
parent
3069e28dd8
commit
b697c6b9da
2 changed files with 2 additions and 14 deletions
13
P2P/IO.hs
13
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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue