git.iko.soy/distributed-process
on master help sign in
More robust test
commit27b723d48cf5f68a9f0dcf9a626fdbb294e133cd authorEdsko de Vries <edsko@edsko.net> dateWed 6 Jun 2012, 10:06 (14 years ago) parentdc2e1d8
1 file changed+11−6
network-transport/tests/TestTCP.hs+11−6
network-transport/tests/TestTCP.hs+11−6
@@ -496,15 +496,20 @@ testUnnecessaryConnect nextPort numThreads = do
496496 dones <- replicateM numThreads $ do
497497 done <- newEmptyMVar
498498 forkTry $ do
499− Right (_, reply) <- readMVar serverAddr >>= \addr -> socketToEndPoint ourAddress addr True Nothing
500− case reply of
501− ConnectionRequestAccepted ->
499+ -- It is possible that the remote endpoint just rejects the request by closing the socket
500+ -- immediately (depending on far the remote endpoint got with the initialization)
501+ response <- readMVar serverAddr >>= \addr -> socketToEndPoint ourAddress addr True Nothing
502+ case response of
503+ Right (_, ConnectionRequestAccepted) ->
504+ -- We don't close this socket because we want to keep this connection open
502505 putMVar gotAccepted ()
503506 -- We might get either Invalid or Crossed (the transport does not
504507 -- maintain enough history to be able to tell)
505− ConnectionRequestInvalid ->
506− return ()
507− ConnectionRequestCrossed ->
508+ Right (sock, ConnectionRequestInvalid) ->
509+ N.sClose sock
510+ Right (sock, ConnectionRequestCrossed) ->
511+ N.sClose sock
512+ Left _ ->
508513 return ()
509514 putMVar done ()
510515 return done