summaryrefslogtreecommitdiff
path: root/src/Erebos/Network.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2024-04-30 21:51:58 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2024-05-02 21:57:20 +0200
commit61f745b3c57e4fe78bea8f8a7a48923b364dd874 (patch)
tree264e53a280ded415ed1a356d672fab6da59bd0c9 /src/Erebos/Network.hs
parent2997edf4874a4d0a8eafe42d0082ff0110f4ed39 (diff)
Network: fail when no free stream is available
Diffstat (limited to 'src/Erebos/Network.hs')
-rw-r--r--src/Erebos/Network.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Erebos/Network.hs b/src/Erebos/Network.hs
index 7c6a61e..744c476 100644
--- a/src/Erebos/Network.hs
+++ b/src/Erebos/Network.hs
@@ -433,7 +433,10 @@ openStream = do
conn <- readTVarP peerConnection >>= \case
Right conn -> return conn
_ -> throwError "can't open stream without established connection"
- (hdr, writer, handler) <- liftSTM $ connAddWriteStream conn
+ (hdr, writer, handler) <- liftSTM (connAddWriteStream conn) >>= \case
+ Right res -> return res
+ Left err -> throwError err
+
liftSTM $ writeTQueue (serverIOActions peerServer_) (liftIO $ forkServerThread peerServer_ handler)
addHeader hdr
return writer