From 61f745b3c57e4fe78bea8f8a7a48923b364dd874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Tue, 30 Apr 2024 21:51:58 +0200 Subject: Network: fail when no free stream is available --- src/Erebos/Network.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/Erebos/Network.hs') 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 -- cgit v1.2.3