File tree Expand file tree Collapse file tree 2 files changed +14
-15
lines changed Expand file tree Collapse file tree 2 files changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -51,20 +51,18 @@ bind s a = case a of
5151 -- domain sockets, inspired by https://stackoverflow.com/a/13719866
5252 res <- try (G. bind s a)
5353 case res of
54- Right () -> pure ()
55- Left e -> if not (isAlreadyInUseError (e :: IOException ))
56- then throwIO e
57- else do
58- -- socket might be in use, try to connect
59- res2 <- try (G. connect s a)
60- case res2 of
61- Right () -> close s >> throwIO e
62- Left e2 -> if not (isDoesNotExistError (e2 :: IOException ))
63- then throwIO e
64- else do
65- -- socket not actually in use, remove it and retry bind
66- removeFile p
67- G. bind s a
54+ Right () -> return ()
55+ Left e | not (isAlreadyInUseError e) -> throwIO (e :: IOException )
56+ Left e | otherwise -> do
57+ -- socket might be in use, try to connect
58+ res2 <- try (G. connect s a)
59+ case res2 of
60+ Right () -> close s >> throwIO e
61+ Left e2 | not (isDoesNotExistError e2) -> throwIO (e2 :: IOException )
62+ _ -> do
63+ -- socket not actually in use, remove it and retry bind
64+ removeFile p
65+ G. bind s a
6866 _ -> G. bind s a
6967
7068-- | Accept a connection. The socket must be bound to an address and
Original file line number Diff line number Diff line change @@ -77,7 +77,8 @@ spec = do
7777 sock1 <- socket AF_UNIX Stream defaultProtocol
7878 tryIOError (bind sock1 addr) >>= \ o -> case o of
7979 Right () -> error " bind should have failed but succeeded"
80- Left e -> if isAlreadyInUseError e then pure () else ioError e
80+ Left e | not (isAlreadyInUseError e) -> ioError e
81+ _ -> return ()
8182
8283 close sock0
8384
You can’t perform that action at this time.
0 commit comments