@@ -48,12 +48,12 @@ import qualified Data.Set as Set
4848 , member
4949 , toList
5050 )
51- import Data.Foldable (forM_ )
51+ import Data.Foldable (forM_ , traverse_ )
5252import Data.Maybe (isJust , fromJust , isNothing , catMaybes )
5353import Data.Typeable (Typeable )
5454import Control.Category ((>>>) )
5555import Control.Applicative (Applicative , (<$>) )
56- import Control.Monad (void , when )
56+ import Control.Monad (void , when , unless )
5757import Control.Monad.IO.Class (MonadIO , liftIO )
5858import Control.Monad.State.Strict (MonadState , StateT , evalStateT , gets )
5959import qualified Control.Monad.State.Strict as StateT (get , put )
@@ -845,8 +845,15 @@ ncEffectRegister from label atnode mPid reregistration = do
845845 then do when (isOk) $
846846 do modify' $ registeredHereFor label ^= mPid
847847 updateRemote node currentVal mPid
848+ traverse_ (\ pid -> unless (isLocal node (ProcessIdentifier pid))
849+ (forward node (NodeIdentifier $ localNodeId node)
850+ (processNodeId pid) (Link $ ProcessIdentifier pid)))
851+ currentVal
848852 case mPid of
849- (Just p) -> liftIO $ trace node (MxRegistered p label)
853+ (Just p) -> do unless (isLocal node (ProcessIdentifier p))
854+ (forward node (NodeIdentifier $ localNodeId node)
855+ (processNodeId p) (Link $ ProcessIdentifier p))
856+ liftIO $ trace node (MxRegistered p label)
850857 Nothing -> liftIO $ trace node (MxUnRegistered (fromJust currentVal) label)
851858 liftIO $ sendMessage node
852859 (NodeIdentifier (localNodeId node))
@@ -861,12 +868,12 @@ ncEffectRegister from label atnode mPid reregistration = do
861868 Nothing -> return ()
862869 Just pid -> modify' $ registeredOnNodesFor pid ^: (maybeify $ operation atnode)
863870 where updateRemote node (Just oldval) (Just newval) | processNodeId oldval /= processNodeId newval =
864- do forward node (processNodeId oldval) (Register label atnode (Just oldval) True )
865- forward node (processNodeId newval) (Register label atnode (Just newval) False )
871+ do forward node (ProcessIdentifier from) ( processNodeId oldval) (Register label atnode (Just oldval) True )
872+ forward node (ProcessIdentifier from) ( processNodeId newval) (Register label atnode (Just newval) False )
866873 updateRemote node Nothing (Just newval) =
867- forward node (processNodeId newval) (Register label atnode (Just newval) False )
874+ forward node (ProcessIdentifier from) ( processNodeId newval) (Register label atnode (Just newval) False )
868875 updateRemote node (Just oldval) Nothing =
869- forward node (processNodeId oldval) (Register label atnode (Just oldval) True )
876+ forward node (ProcessIdentifier from) ( processNodeId oldval) (Register label atnode (Just oldval) True )
870877 updateRemote _ _ _ = return ()
871878 maybeify f Nothing = unmaybeify $ f []
872879 maybeify f (Just x) = unmaybeify $ f x
@@ -880,10 +887,10 @@ ncEffectRegister from label atnode mPid reregistration = do
880887 decList ((atag,1 ): xs) tag | atag == tag = xs
881888 decList ((atag,n): xs) tag | atag == tag = (atag,n- 1 ): xs
882889 decList (x: xs) tag = x: decList xs tag
883- forward node to reg =
890+ forward node from' to reg =
884891 when (not $ isLocal node (NodeIdentifier to)) $
885892 liftIO $ sendBinary node
886- ( ProcessIdentifier from)
893+ from'
887894 (NodeIdentifier to)
888895 WithImplicitReconnect
889896 NCMsg
@@ -892,6 +899,7 @@ ncEffectRegister from label atnode mPid reregistration = do
892899 }
893900
894901
902+
895903-- Unified semantics does not explicitly describe 'whereis'
896904ncEffectWhereIs :: ProcessId -> String -> NC ()
897905ncEffectWhereIs from label = do
0 commit comments