@@ -1112,8 +1112,10 @@ registerImpl force label pid = do
1112
1112
--
1113
1113
-- See comments in 'whereisRemoteAsync'
1114
1114
registerRemoteAsync :: NodeId -> String -> ProcessId -> Process ()
1115
- registerRemoteAsync nid label pid =
1116
- sendCtrlMsg (Just nid) (Register label nid (Just pid) False )
1115
+ registerRemoteAsync nid label pid = do
1116
+ here <- getSelfNode
1117
+ sendCtrlMsg (if nid == here then Nothing else Just nid)
1118
+ (Register label nid (Just pid) False )
1117
1119
1118
1120
reregisterRemoteAsync :: NodeId -> String -> ProcessId -> Process ()
1119
1121
reregisterRemoteAsync nid label pid =
@@ -1165,8 +1167,9 @@ whereis label = do
1165
1167
-- use 'monitorNode' and take appropriate action when you receive a
1166
1168
-- 'NodeMonitorNotification').
1167
1169
whereisRemoteAsync :: NodeId -> String -> Process ()
1168
- whereisRemoteAsync nid label =
1169
- sendCtrlMsg (Just nid) (WhereIs label)
1170
+ whereisRemoteAsync nid label = do
1171
+ here <- getSelfNode
1172
+ sendCtrlMsg (if nid == here then Nothing else Just nid) (WhereIs label)
1170
1173
1171
1174
-- | Named send to a process in the local registry (asynchronous)
1172
1175
nsend :: Serializable a => String -> a -> Process ()
@@ -1182,8 +1185,10 @@ unsafeNSend = Unsafe.nsend
1182
1185
1183
1186
-- | Named send to a process in a remote registry (asynchronous)
1184
1187
nsendRemote :: Serializable a => NodeId -> String -> a -> Process ()
1185
- nsendRemote nid label msg =
1186
- sendCtrlMsg (Just nid) (NamedSend label (createMessage msg))
1188
+ nsendRemote nid label msg = do
1189
+ here <- getSelfNode
1190
+ if here == nid then nsend label msg
1191
+ else sendCtrlMsg (Just nid) (NamedSend label (createMessage msg))
1187
1192
1188
1193
-- | Named send to a process in a remote registry (asynchronous)
1189
1194
-- This function makes /no/ attempt to serialize and (in the case when the
0 commit comments