@@ -48,12 +48,12 @@ import qualified Data.Set as Set
48
48
, member
49
49
, toList
50
50
)
51
- import Data.Foldable (forM_ )
51
+ import Data.Foldable (forM_ , traverse_ )
52
52
import Data.Maybe (isJust , fromJust , isNothing , catMaybes )
53
53
import Data.Typeable (Typeable )
54
54
import Control.Category ((>>>) )
55
55
import Control.Applicative (Applicative , (<$>) )
56
- import Control.Monad (void , when )
56
+ import Control.Monad (void , when , unless )
57
57
import Control.Monad.IO.Class (MonadIO , liftIO )
58
58
import Control.Monad.State.Strict (MonadState , StateT , evalStateT , gets )
59
59
import qualified Control.Monad.State.Strict as StateT (get , put )
@@ -845,8 +845,15 @@ ncEffectRegister from label atnode mPid reregistration = do
845
845
then do when (isOk) $
846
846
do modify' $ registeredHereFor label ^= mPid
847
847
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
848
852
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)
850
857
Nothing -> liftIO $ trace node (MxUnRegistered (fromJust currentVal) label)
851
858
liftIO $ sendMessage node
852
859
(NodeIdentifier (localNodeId node))
@@ -861,12 +868,12 @@ ncEffectRegister from label atnode mPid reregistration = do
861
868
Nothing -> return ()
862
869
Just pid -> modify' $ registeredOnNodesFor pid ^: (maybeify $ operation atnode)
863
870
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 )
866
873
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 )
868
875
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 )
870
877
updateRemote _ _ _ = return ()
871
878
maybeify f Nothing = unmaybeify $ f []
872
879
maybeify f (Just x) = unmaybeify $ f x
@@ -880,10 +887,10 @@ ncEffectRegister from label atnode mPid reregistration = do
880
887
decList ((atag,1 ): xs) tag | atag == tag = xs
881
888
decList ((atag,n): xs) tag | atag == tag = (atag,n- 1 ): xs
882
889
decList (x: xs) tag = x: decList xs tag
883
- forward node to reg =
890
+ forward node from' to reg =
884
891
when (not $ isLocal node (NodeIdentifier to)) $
885
892
liftIO $ sendBinary node
886
- ( ProcessIdentifier from)
893
+ from'
887
894
(NodeIdentifier to)
888
895
WithImplicitReconnect
889
896
NCMsg
@@ -892,6 +899,7 @@ ncEffectRegister from label atnode mPid reregistration = do
892
899
}
893
900
894
901
902
+
895
903
-- Unified semantics does not explicitly describe 'whereis'
896
904
ncEffectWhereIs :: ProcessId -> String -> NC ()
897
905
ncEffectWhereIs from label = do
0 commit comments