git.iko.soy/distributed-process
on master help sign in
Merge pull request #262 from haskell-distributed/fd/nsendRemote-skips-transport
10c6034Facundo Domínguez
src/Control/Distributed/Process/Internal/Primitives.hs+11−6
@@ -1112,8 +1112,10 @@ registerImpl force label pid = do
1112--
1112--
1113-- See comments in 'whereisRemoteAsync'
1113-- See comments in 'whereisRemoteAsync'
1114registerRemoteAsync :: NodeId -> String -> ProcessId -> Process ()
1114registerRemoteAsync :: NodeId -> String -> ProcessId -> Process ()
1115−registerRemoteAsync nid label pid =
1115+registerRemoteAsync nid label pid = do
1116+ here <- getSelfNode
1117+ sendCtrlMsg (if nid == here then Nothing else Just nid)
1116− sendCtrlMsg (Just nid) (Register label nid (Just pid) False)
1118+ (Register label nid (Just pid) False)
1117
1119
1118reregisterRemoteAsync :: NodeId -> String -> ProcessId -> Process ()
1120reregisterRemoteAsync :: NodeId -> String -> ProcessId -> Process ()
1119reregisterRemoteAsync nid label pid =
1121reregisterRemoteAsync nid label pid =
@@ -1165,8 +1167,9 @@ whereis label = do
1165-- use 'monitorNode' and take appropriate action when you receive a
1167-- use 'monitorNode' and take appropriate action when you receive a
1166-- 'NodeMonitorNotification').
1168-- 'NodeMonitorNotification').
1167whereisRemoteAsync :: NodeId -> String -> Process ()
1169whereisRemoteAsync :: NodeId -> String -> Process ()
1168−whereisRemoteAsync nid label =
1170+whereisRemoteAsync nid label = do
1171+ here <- getSelfNode
1169− sendCtrlMsg (Just nid) (WhereIs label)
1172+ sendCtrlMsg (if nid == here then Nothing else Just nid) (WhereIs label)
1170
1173
1171-- | Named send to a process in the local registry (asynchronous)
1174-- | Named send to a process in the local registry (asynchronous)
1172nsend :: Serializable a => String -> a -> Process ()
1175nsend :: Serializable a => String -> a -> Process ()
@@ -1182,8 +1185,10 @@ unsafeNSend = Unsafe.nsend
1182
1185
1183-- | Named send to a process in a remote registry (asynchronous)
1186-- | Named send to a process in a remote registry (asynchronous)
1184nsendRemote :: Serializable a => NodeId -> String -> a -> Process ()
1187nsendRemote :: Serializable a => NodeId -> String -> a -> Process ()
1185−nsendRemote nid label msg =
1188+nsendRemote nid label msg = do
1189+ here <- getSelfNode
1190+ if here == nid then nsend label msg
1186− sendCtrlMsg (Just nid) (NamedSend label (createMessage msg))
1191+ else sendCtrlMsg (Just nid) (NamedSend label (createMessage msg))
1187
1192
1188-- | Named send to a process in a remote registry (asynchronous)
1193-- | Named send to a process in a remote registry (asynchronous)
1189-- This function makes /no/ attempt to serialize and (in the case when the
1194-- This function makes /no/ attempt to serialize and (in the case when the