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
51
51
-- domain sockets, inspired by https://stackoverflow.com/a/13719866
52
52
res <- try (G. bind s a)
53
53
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
68
66
_ -> G. bind s a
69
67
70
68
-- | 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
77
77
sock1 <- socket AF_UNIX Stream defaultProtocol
78
78
tryIOError (bind sock1 addr) >>= \ o -> case o of
79
79
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 ()
81
82
82
83
close sock0
83
84
You can’t perform that action at this time.
0 commit comments