@@ -20,6 +20,7 @@ import qualified Network.Transport as NT
2020 , defaultConnectHints
2121 , connect
2222 , Reliability(ReliableOrdered)
23+ , close
2324 )
2425import Control.Distributed.Process.Internal.Types
2526 ( LocalNode(localState, localEndPoint, localCtrlChan)
@@ -94,5 +95,10 @@ connBetween node from to = do
9495
9596reconnect :: LocalNode -> Identifier -> Identifier -> IO ()
9697reconnect node from to =
97− modifyMVar_ (localState node) $ return .
98− (localConnectionBetween from to ^= Nothing)
98+ modifyMVar_ (localState node) $ \st ->
99+ case st ^. localConnectionBetween from to of
100+ Nothing ->
101+ return st
102+ Just conn -> do
103+ NT.close conn
104+ return (localConnectionBetween from to ^= Nothing $ st)