Fix STM blocking on connecting
When attempting to connect to an address that doesn't exist, startEuphConnection now doesn't result in a thread blocked by an STM transaction any more. It now throws a simple ConnectionFailed exception.
This commit is contained in:
parent
d818aba337
commit
2fd045d59b
1 changed files with 6 additions and 3 deletions
|
|
@ -107,13 +107,16 @@ startEuphConnection host room = do
|
||||||
let euphCon = Connection locked sendQueue eventQueue
|
let euphCon = Connection locked sendQueue eventQueue
|
||||||
void
|
void
|
||||||
$ forkIO
|
$ forkIO
|
||||||
$ handle (handleException eventQueue)
|
$ handle (handleIOException eventQueue)
|
||||||
|
$ handle (handleHandshakeException eventQueue)
|
||||||
$ WSS.runSecureClient host 443 ("/room/" ++ room ++ "/ws")
|
$ WSS.runSecureClient host 443 ("/room/" ++ room ++ "/ws")
|
||||||
$ recvClient euphCon
|
$ recvClient euphCon
|
||||||
return euphCon
|
return euphCon
|
||||||
where
|
where
|
||||||
handleException :: EventQueue -> WS.HandshakeException -> IO ()
|
handleHandshakeException :: EventQueue -> WS.HandshakeException -> IO ()
|
||||||
handleException qEvent _ = atomically $ writeTBQueue qEvent ConnectionFailed
|
handleHandshakeException qEvent _ = atomically $ writeTBQueue qEvent ConnectionFailed
|
||||||
|
handleIOException :: EventQueue -> IOException -> IO ()
|
||||||
|
handleIOException qEvent _ = atomically $ writeTBQueue qEvent ConnectionFailed
|
||||||
|
|
||||||
{-
|
{-
|
||||||
- Send thread
|
- Send thread
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue