git.iko.soy/distributed-process
on master help sign in
More robust test
27b723dEdsko de Vries
network-transport/tests/TestTCP.hs+11−6
@@ -496,15 +496,20 @@ testUnnecessaryConnect nextPort numThreads = do
496 dones <- replicateM numThreads $ do
496 dones <- replicateM numThreads $ do
497 done <- newEmptyMVar
497 done <- newEmptyMVar
498 forkTry $ do
498 forkTry $ do
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)
499− Right (_, reply) <- readMVar serverAddr >>= \addr -> socketToEndPoint ourAddress addr True Nothing
501+ response <- readMVar serverAddr >>= \addr -> socketToEndPoint ourAddress addr True Nothing
500− case reply of
502+ case response of
501− ConnectionRequestAccepted ->
503+ Right (_, ConnectionRequestAccepted) ->
504+ -- We don't close this socket because we want to keep this connection open
502 putMVar gotAccepted ()
505 putMVar gotAccepted ()
503 -- We might get either Invalid or Crossed (the transport does not
506 -- We might get either Invalid or Crossed (the transport does not
504 -- maintain enough history to be able to tell)
507 -- maintain enough history to be able to tell)
505− ConnectionRequestInvalid ->
508+ Right (sock, ConnectionRequestInvalid) ->
506− return ()
509+ N.sClose sock
507− ConnectionRequestCrossed ->
510+ Right (sock, ConnectionRequestCrossed) ->
511+ N.sClose sock
512+ Left _ ->
508 return ()
513 return ()
509 putMVar done ()
514 putMVar done ()
510 return done
515 return done