@@ -37,6 +37,7 @@ import qualified Data.Map as Map
3737 , filterWithKey
3838 , foldlWithKey
3939 )
40+import qualified Data.Set as Set
4041import Data.Time.Format (formatTime)
4142#if MIN_VERSION_time(1,5,0)
4243import Data.Time.Format (defaultTimeLocale)
@@ -879,6 +880,18 @@ ncEffectDied ident reason = do
879880 when (localOnly <= isLocal node (ProcessIdentifier us)) $
880881 notifyDied us them reason (Just ref)
881882
883+ -- Notify remote nodes that the process died so it can be removed from monitor
884+ -- lists.
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
892+ ]
893+
894+ -- Delete monitors in the local node.
882895 let deleteDeads :: (Ord a, Ord v)
883896 => BiMultiMap a ProcessId v -> BiMultiMap a ProcessId v
884897 deleteDeads = case ident of
@@ -899,12 +912,12 @@ ncEffectDied ident reason = do
899912 True ->
900913 do forM_ nidlist $ \(nid,_) ->
901914 when (not $ isLocal node (NodeIdentifier nid))
902− (forwardNameDeath node nid)
915+ (forwardDeath node nid)
903916 return Nothing
904917 False -> return $ Just (pid,nidlist) )
905918 modify' $ registeredOnNodes ^= (Map.fromList (catMaybes remaining))
906919 where
907− forwardNameDeath node nid = ncSendToNode nid
920+ forwardDeath node nid = ncSendToNode nid
908921 NCMsg { ctrlMsgSender = NodeIdentifier (localNodeId node)
909922 , ctrlMsgSignal = Died ident reason
910923 }
@@ -1059,9 +1072,9 @@ ncEffectGetInfo from pid =
10591072 Nothing -> dispatch (isLocal node (ProcessIdentifier from))
10601073 from (ProcessInfoNone DiedUnknownId)
10611074 Just proc -> do
1062− itsLinks <- Set.map fst . BiMultiMap.lookup them <$>
1075+ itsLinks <- Set.map fst . BiMultiMap.lookupBy1st them <$>
10631076 gets (^. links)
1064− itsMons <- BiMultiMap.lookup them <$> gets (^. monitors)
1077+ itsMons <- BiMultiMap.lookupBy1st them <$> gets (^. monitors)
10651078 registered <- gets (^. registeredHere)
10661079 size <- liftIO $ queueSize $ processQueue $ proc
10671080