diff options
author | Joe Crayne <joe@jerkface.net> | 2018-12-10 14:25:23 -0500 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2018-12-16 14:08:26 -0500 |
commit | d27be4aaf8182bc8c5dd84c7b8cc7f5250614613 (patch) | |
tree | 98397bc63ec1cf173be9727642ae11514de7d201 /src | |
parent | 2a9f75cbde498f69d1522caedda27dbfc2207bef (diff) |
Exception handling for TCP-relay client connect.
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/QueryResponse/TCP.hs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/Network/QueryResponse/TCP.hs b/src/Network/QueryResponse/TCP.hs index c0bdcd3c..154e9145 100644 --- a/src/Network/QueryResponse/TCP.hs +++ b/src/Network/QueryResponse/TCP.hs | |||
@@ -67,9 +67,12 @@ acquireConnection mvar tcpcache stream addr = do | |||
67 | case MM.lookup' (TCPAddress $ streamAddr stream addr) cache of | 67 | case MM.lookup' (TCPAddress $ streamAddr stream addr) cache of |
68 | Nothing -> do | 68 | Nothing -> do |
69 | proto <- getProtocolNumber "tcp" | 69 | proto <- getProtocolNumber "tcp" |
70 | sock <- socket (socketFamily $ streamAddr stream addr) Stream proto | 70 | mh <- catchIOError (do sock <- socket (socketFamily $ streamAddr stream addr) Stream proto |
71 | connect sock (streamAddr stream addr) `catchIOError` (\e -> close sock) | 71 | connect sock (streamAddr stream addr) `catchIOError` (\e -> close sock) |
72 | h <- socketToHandle sock ReadWriteMode | 72 | h <- socketToHandle sock ReadWriteMode |
73 | return $ Just h) | ||
74 | $ \e -> return Nothing | ||
75 | fmap join $ forM mh $ \h -> do | ||
73 | st <- streamHello stream addr h | 76 | st <- streamHello stream addr h |
74 | t <- getPOSIXTime | 77 | t <- getPOSIXTime |
75 | rthread <- forkIO $ fix $ \loop -> do | 78 | rthread <- forkIO $ fix $ \loop -> do |