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