Skip to content

Commit 17c06e6

Browse files
Skip the transport for whereisRemoteAsync and registerRemoteAsync.
The transport is skipped when the destination is the local node.
1 parent c67b972 commit 17c06e6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Control/Distributed/Process/Internal/Primitives.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,8 +1103,10 @@ registerImpl force label pid = do
11031103
--
11041104
-- See comments in 'whereisRemoteAsync'
11051105
registerRemoteAsync :: NodeId -> String -> ProcessId -> Process ()
1106-
registerRemoteAsync nid label pid =
1107-
sendCtrlMsg (Just nid) (Register label nid (Just pid) False)
1106+
registerRemoteAsync nid label pid = do
1107+
here <- getSelfNode
1108+
sendCtrlMsg (if nid == here then Nothing else Just nid)
1109+
(Register label nid (Just pid) False)
11081110

11091111
reregisterRemoteAsync :: NodeId -> String -> ProcessId -> Process ()
11101112
reregisterRemoteAsync nid label pid =
@@ -1156,8 +1158,9 @@ whereis label = do
11561158
-- use 'monitorNode' and take appropriate action when you receive a
11571159
-- 'NodeMonitorNotification').
11581160
whereisRemoteAsync :: NodeId -> String -> Process ()
1159-
whereisRemoteAsync nid label =
1160-
sendCtrlMsg (Just nid) (WhereIs label)
1161+
whereisRemoteAsync nid label = do
1162+
here <- getSelfNode
1163+
sendCtrlMsg (if nid == here then Nothing else Just nid) (WhereIs label)
11611164

11621165
-- | Named send to a process in the local registry (asynchronous)
11631166
nsend :: Serializable a => String -> a -> Process ()

0 commit comments

Comments
 (0)