git.iko.soy/distributed-process
on master help sign in
Attempt to close connection in reconnect

This makes it possible for the remote connection to clean up its incoming connections table (in handleIncomingMessages). This fixes yet another memory leak.

commitdb751580d76ea2f8de616c67454db65723002a53 authorEdsko de Vries <edsko@edsko.net> dateWed 15 Aug 2012, 16:13 (14 years ago) parent2e682fb
1 file changed+8−2
distributed-process/src/Control/Distributed/Process/Internal/Node.hs+8−2
distributed-process/src/Control/Distributed/Process/Internal/Node.hs+8−2
@@ -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)