git.iko.soy/distributed-process
on master help sign in
Optional EndPointAddress in EventConnectionLost
commit5ffbd26fd8ec5b520a82d24cf60e7b8a21752e59 authorEdsko de Vries <edsko@edsko.net> dateWed 13 Jun 2012, 17:16 (14 years ago) parent5e9b583
5 files changed+12−10
distributed-process/src/Control/Distributed/Process.hs+1−1 network-transport/src/Network/Transport.hs+4−2 network-transport/src/Network/Transport/TCP.hs+2−2 network-transport/tests/TestTCP.hs+3−3 network-transport/tests/TestTransport.hs+2−2
distributed-process/src/Control/Distributed/Process.hs+1−1
@@ -586,7 +586,7 @@ handleIncomingMessages node = go [] Map.empty Set.empty
586586 go (List.delete cid uninitConns)
587587 (Map.delete cid procConns)
588588 (Set.delete cid ctrlConns)
589− NT.ErrorEvent (NT.TransportError (NT.EventConnectionLost theirAddr _) _) -> do
589+ NT.ErrorEvent (NT.TransportError (NT.EventConnectionLost (Just theirAddr) _) _) -> do
590590 -- TODO: we could cache this information
591591 pids <- withMVar state $ \st ->
592592 return $ filter ((== theirAddr) . nodeAddress . processNodeId)
network-transport/src/Network/Transport.hs+4−2
@@ -218,6 +218,8 @@ data EventErrorCode =
218218 EventEndPointFailed
219219 -- | Transport-wide fatal error
220220 | EventTransportFailed
221− -- | Connection to a remote endpoint was lost
222− | EventConnectionLost EndPointAddress [ConnectionId]
221+ -- | Some incoming connections were closed abruptly.
222+ -- If an endpoint address is specified, then all connections to and
223+ -- from that endpoint are now lost
224+ | EventConnectionLost (Maybe EndPointAddress) [ConnectionId]
223225 deriving (Show, Typeable, Eq)
network-transport/src/Network/Transport/TCP.hs+2−2
@@ -732,7 +732,7 @@ modifyRemoteState (ourEndPoint, theirEndPoint) match =
732732 tryCloseSocket (remoteSocket vst)
733733 putMVar theirState (RemoteEndPointFailed ex)
734734 let incoming = IntSet.elems $ vst ^. remoteIncoming
735− code = EventConnectionLost (remoteAddress theirEndPoint) incoming
735+ code = EventConnectionLost (Just $ remoteAddress theirEndPoint) incoming
736736 err = TransportError code (show ex)
737737 writeChan (localChannel ourEndPoint) $ ErrorEvent err
738738
@@ -1072,7 +1072,7 @@ handleIncomingMessages (ourEndPoint, theirEndPoint) = do
10721072 "handleIncomingMessages:prematureExit"
10731073 RemoteEndPointValid vst -> do
10741074 let code = EventConnectionLost
1075− (remoteAddress theirEndPoint)
1075+ (Just $ remoteAddress theirEndPoint)
10761076 (IntSet.elems $ vst ^. remoteIncoming)
10771077 writeChan ourChannel . ErrorEvent $ TransportError code (show err)
10781078 forM_ (vst ^. pendingCtrlRequests) $ flip putMVar (Left err)
network-transport/tests/TestTCP.hs+3−3
@@ -93,7 +93,7 @@ testEarlyDisconnect nextPort = do
9393 ConnectionOpened cid _ addr <- receive endpoint
9494 True <- return $ addr == theirAddr
9595
96− ErrorEvent (TransportError (EventConnectionLost addr' [cid']) _) <- receive endpoint
96+ ErrorEvent (TransportError (EventConnectionLost (Just addr') [cid']) _) <- receive endpoint
9797 True <- return $ addr' == theirAddr && cid' == cid
9898
9999 return ()
@@ -116,7 +116,7 @@ testEarlyDisconnect nextPort = do
116116 Received cid' ["pong"] <- receive endpoint
117117 True <- return $ cid == cid'
118118
119− ErrorEvent (TransportError (EventConnectionLost addr' [cid'']) _) <- receive endpoint
119+ ErrorEvent (TransportError (EventConnectionLost (Just addr') [cid'']) _) <- receive endpoint
120120 True <- return $ addr' == theirAddr && cid'' == cid
121121
122122 return ()
@@ -227,7 +227,7 @@ testEarlyCloseSocket nextPort = do
227227 ConnectionClosed cid'' <- receive endpoint
228228 True <- return $ cid'' == cid
229229
230− ErrorEvent (TransportError (EventConnectionLost addr' []) _) <- receive endpoint
230+ ErrorEvent (TransportError (EventConnectionLost (Just addr') []) _) <- receive endpoint
231231 True <- return $ addr' == theirAddr
232232
233233 return ()
network-transport/tests/TestTransport.hs+2−2
@@ -598,7 +598,7 @@ testCloseEndPoint transport _ = do
598598 send conn ["pong"]
599599
600600 ConnectionClosed cid'' <- receive endpoint ; True <- return $ cid == cid''
601− ErrorEvent (TransportError (EventConnectionLost addr' []) _) <- receive endpoint ; True <- return $ addr' == theirAddr
601+ ErrorEvent (TransportError (EventConnectionLost (Just addr') []) _) <- receive endpoint ; True <- return $ addr' == theirAddr
602602
603603 Left (TransportError SendFailed _) <- send conn ["pong2"]
604604
@@ -686,7 +686,7 @@ testCloseTransport newTransport = do
686686 evs <- replicateM 3 $ receive endpoint
687687 let expected = [ ConnectionClosed cid1
688688 , ConnectionClosed cid2
689− , ErrorEvent (TransportError (EventConnectionLost theirAddr2 []) "")
689+ , ErrorEvent (TransportError (EventConnectionLost (Just theirAddr2) []) "")
690690 ]
691691 True <- return $ any (== expected) (permutations evs)
692692