@@ -12,7 +12,7 @@ import Network.Socket
12
12
import Network.Socket.ByteString
13
13
import Network.Test.Common
14
14
import System.Mem (performGC )
15
- import System.IO.Error (tryIOError , isAlreadyInUseError )
15
+ import System.IO.Error (tryIOError )
16
16
import System.IO.Temp (withSystemTempDirectory )
17
17
import Foreign.C.Types ()
18
18
@@ -70,9 +70,12 @@ spec = do
70
70
bind sock (addrAddress addr) `shouldThrow` anyIOException
71
71
#endif
72
72
73
- it " successfully binds to a unix socket, twice " $ do
73
+ it " successfully binds to a unix socket" $ do
74
74
withSystemTempDirectory " haskell-network" $ \ path -> do
75
75
let sfile = path ++ " /socket-file"
76
+ -- exist <- doesFileExist sfile
77
+ -- when exist $ removeFile sfile
78
+ -- removeFile sfile
76
79
let addr = SockAddrUnix sfile
77
80
when (isSupportedSockAddr addr) $ do
78
81
sock0 <- socket AF_UNIX Stream defaultProtocol
@@ -82,23 +85,10 @@ spec = do
82
85
sock1 <- socket AF_UNIX Stream defaultProtocol
83
86
tryIOError (bind sock1 addr) >>= \ o -> case o of
84
87
Right () -> error " bind should have failed but succeeded"
85
- Left e | not (isAlreadyInUseError e) -> ioError e
86
- _ -> return ()
88
+ _ -> return ()
87
89
88
90
close sock0
89
-
90
- -- Unix systems tend to leave the file existing, which is
91
- -- why our `bind` does its workaround. however if any
92
- -- system in the future does fix this issue, we don't want
93
- -- this test to fail, since that would defeat the purpose
94
- -- of our workaround. but you can uncomment the below lines
95
- -- if you want to play with this on your own system.
96
- -- import System.Directory (doesPathExist)
97
- -- ex <- doesPathExist sfile
98
- -- unless ex $ error "socket file was deleted unexpectedly"
99
-
100
- sock2 <- socket AF_UNIX Stream defaultProtocol
101
- bind sock2 addr
91
+ close sock1
102
92
103
93
describe " UserTimeout" $ do
104
94
it " can be set" $ do
0 commit comments