diff options
author | joe <joe@jerkface.net> | 2014-02-15 22:37:11 -0500 |
---|---|---|
committer | joe <joe@jerkface.net> | 2014-02-15 22:37:11 -0500 |
commit | 9d01ddf6dabc1fdd1a40d7f79b7d21d3e2c6baf1 (patch) | |
tree | ede15cedce07f5428d889abfacfc4ed530bbbaab /Presence/Server.hs | |
parent | 7e22f875d6e626a8a37f6e02423d4cc73004348d (diff) |
Answer client bind-resource request. Quieted connect-fail messages.
Diffstat (limited to 'Presence/Server.hs')
-rw-r--r-- | Presence/Server.hs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/Presence/Server.hs b/Presence/Server.hs index a1c4923b..baf5a1a8 100644 --- a/Presence/Server.hs +++ b/Presence/Server.hs | |||
@@ -42,7 +42,7 @@ import Control.Monad.Fix | |||
42 | -- import Control.Monad.STM | 42 | -- import Control.Monad.STM |
43 | import Control.Monad.Trans.Resource | 43 | import Control.Monad.Trans.Resource |
44 | import Control.Monad.IO.Class (MonadIO (liftIO)) | 44 | import Control.Monad.IO.Class (MonadIO (liftIO)) |
45 | import System.IO.Error (ioeGetErrorType) | 45 | import System.IO.Error (ioeGetErrorType,isDoesNotExistError) |
46 | import System.IO | 46 | import System.IO |
47 | ( IOMode(..) | 47 | ( IOMode(..) |
48 | , hSetBuffering | 48 | , hSetBuffering |
@@ -311,18 +311,17 @@ server = do | |||
311 | where | 311 | where |
312 | forkit = void . forkIO $ do | 312 | forkit = void . forkIO $ do |
313 | proto <- getProtocolNumber "tcp" | 313 | proto <- getProtocolNumber "tcp" |
314 | sock <- bracketOnError | 314 | sock <- socket (socketFamily addr) Stream proto |
315 | (socket (socketFamily addr) Stream proto) | 315 | handle (\e -> do -- let t = ioeGetErrorType e |
316 | (\sock -> do -- only done if there's an error | 316 | when (isDoesNotExistError e) $ return () -- warn "GOTCHA" |
317 | -- Weird hack: puting the would-be peer address | 317 | -- warn $ "connect-error: " <> bshow e |
318 | -- instead of local socketName | ||
319 | conkey <- makeConnKey params (sock,addr) -- XXX: ? | 318 | conkey <- makeConnKey params (sock,addr) -- XXX: ? |
320 | sClose sock | 319 | sClose sock |
321 | atomically | 320 | atomically |
322 | $ writeTChan (serverEvent server) | 321 | $ writeTChan (serverEvent server) |
323 | $ (conkey,ConnectFailure addr)) | 322 | $ (conkey,ConnectFailure addr)) |
324 | $ \sock -> do connect sock addr | 323 | $ do |
325 | return sock | 324 | connect sock addr |
326 | me <- getSocketName sock | 325 | me <- getSocketName sock |
327 | conkey <- makeConnKey params (sock,me) | 326 | conkey <- makeConnKey params (sock,me) |
328 | h <- socketToHandle sock ReadWriteMode | 327 | h <- socketToHandle sock ReadWriteMode |
@@ -350,9 +349,10 @@ server = do | |||
350 | fix $ \retryLoop -> do | 349 | fix $ \retryLoop -> do |
351 | utc <- getCurrentTime | 350 | utc <- getCurrentTime |
352 | forkIO $ do | 351 | forkIO $ do |
353 | sock <- bracketOnError | 352 | sock <- socket (socketFamily addr) Stream proto |
354 | (socket (socketFamily addr) Stream proto) | 353 | handle (\e -> do -- let t = ioeGetErrorType e |
355 | (\sock -> do -- only done if there's an error | 354 | when (isDoesNotExistError e) $ return () -- warn "GOTCHA" |
355 | -- warn $ "connect-error: " <> bshow e | ||
356 | -- Weird hack: puting the would-be peer address | 356 | -- Weird hack: puting the would-be peer address |
357 | -- instead of local socketName | 357 | -- instead of local socketName |
358 | conkey <- makeConnKey params (sock,addr) -- XXX: ? | 358 | conkey <- makeConnKey params (sock,addr) -- XXX: ? |
@@ -362,8 +362,8 @@ server = do | |||
362 | $ (conkey,ConnectFailure addr) | 362 | $ (conkey,ConnectFailure addr) |
363 | retry <- readTVar retryVar | 363 | retry <- readTVar retryVar |
364 | putTMVar resultVar retry) | 364 | putTMVar resultVar retry) |
365 | $ \sock -> do connect sock addr | 365 | $ do |
366 | return sock | 366 | connect sock addr |
367 | me <- getSocketName sock | 367 | me <- getSocketName sock |
368 | conkey <- makeConnKey params (sock,me) | 368 | conkey <- makeConnKey params (sock,me) |
369 | h <- socketToHandle sock ReadWriteMode | 369 | h <- socketToHandle sock ReadWriteMode |