@@ -45,6 +45,7 @@ import qualified Data.Set as Set
49import Data.Foldable (forM_)
50import Data.Foldable (forM_)
50import Data.List (foldl')
51import Data.List (foldl')
@@ -879,6 +880,18 @@ ncEffectDied ident reason = do
879 when (localOnly <= isLocal node (ProcessIdentifier us)) $
880 when (localOnly <= isLocal node (ProcessIdentifier us)) $
880 notifyDied us them reason (Just ref)
881 notifyDied us them reason (Just ref)
883+ -- Notify remote nodes that the process died so it can be removed from monitor
885+ mapM_ (forwardDeath node) $
886+ [ nid | ProcessIdentifier pid <- [ident]
887+ , i <- Set.toList $ Set.union
888+ (Set.map fst $ BiMultiMap.lookupBy2nd pid unaffectedLinks)
889+ (Set.map fst $ BiMultiMap.lookupBy2nd pid unaffectedMons)
890+ , let nid = nodeOf i
891+ , nid /= localNodeId node
894+ -- Delete monitors in the local node.
882 let deleteDeads :: (Ord a, Ord v)
895 let deleteDeads :: (Ord a, Ord v)
883 => BiMultiMap a ProcessId v -> BiMultiMap a ProcessId v
896 => BiMultiMap a ProcessId v -> BiMultiMap a ProcessId v
884 deleteDeads = case ident of
897 deleteDeads = case ident of
@@ -899,12 +912,12 @@ ncEffectDied ident reason = do
900 do forM_ nidlist $ \(nid,_) ->
913 do forM_ nidlist $ \(nid,_) ->
901 when (not $ isLocal node (NodeIdentifier nid))
914 when (not $ isLocal node (NodeIdentifier nid))
902− (forwardNameDeath node nid)
915+ (forwardDeath node nid)
903 return Nothing
916 return Nothing
904 False -> return $ Just (pid,nidlist) )
917 False -> return $ Just (pid,nidlist) )
905 modify' $ registeredOnNodes ^= (Map.fromList (catMaybes remaining))
918 modify' $ registeredOnNodes ^= (Map.fromList (catMaybes remaining))
907− forwardNameDeath node nid = ncSendToNode nid
920+ forwardDeath node nid = ncSendToNode nid
908 NCMsg { ctrlMsgSender = NodeIdentifier (localNodeId node)
921 NCMsg { ctrlMsgSender = NodeIdentifier (localNodeId node)
909 , ctrlMsgSignal = Died ident reason
922 , ctrlMsgSignal = Died ident reason
@@ -1059,9 +1072,9 @@ ncEffectGetInfo from pid =
1059 Nothing -> dispatch (isLocal node (ProcessIdentifier from))
1072 Nothing -> dispatch (isLocal node (ProcessIdentifier from))
1060 from (ProcessInfoNone DiedUnknownId)
1073 from (ProcessInfoNone DiedUnknownId)
1061 Just proc -> do
1074 Just proc -> do
1062− itsLinks <- Set.map fst . BiMultiMap.lookup them <$>
1075+ itsLinks <- Set.map fst . BiMultiMap.lookupBy1st them <$>
1063 gets (^. links)
1076 gets (^. links)
1064− itsMons <- BiMultiMap.lookup them <$> gets (^. monitors)
1077+ itsMons <- BiMultiMap.lookupBy1st them <$> gets (^. monitors)
1065 registered <- gets (^. registeredHere)
1078 registered <- gets (^. registeredHere)
1066 size <- liftIO $ queueSize $ processQueue $ proc
1079 size <- liftIO $ queueSize $ processQueue $ proc