<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
sorry for the untitled email<br>
<br>
<div class="moz-cite-prefix">On 2016/3/15 17:31, Khitai Pang wrote:<br>
</div>
<blockquote cite="mid:COL127-W3765B3912666CD277C07BEFC890@phx.gbl"
type="cite">
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:新細明體
}
--></style>
<div dir="ltr">I have been trying to use gproc with
<a class="moz-txt-link-freetext" href="https://github.com/garret-smith/gen_leader_revival">https://github.com/garret-smith/gen_leader_revival</a>. I found
that registering a name which is already registered will destroy
the existing registration of the name, and a remote node is
unaware of this. See the following steps:<br>
<br>
<br>
Register node1 shell as global name 'abcde' on node1, the name
is visable on node2 and sending messages from node2 shell to
'abcde' works fine:<br>
<br>
<tt>(node1)1> gproc:reg({n, g, abcde}).</tt><tt><br>
</tt><tt>true</tt><tt><br>
</tt><tt>(node1)2> gproc:where({n, g, abcde}).</tt><tt><br>
</tt><tt><0.229.0></tt><tt><br>
</tt><tt><br>
</tt><tt>(node2)1> gproc:where({n, g, abcde}).</tt><tt><br>
</tt><tt><8049.229.0></tt><tt><br>
</tt><tt>(node2)2> gproc:send({n, g, abcde}, hello).</tt><tt><br>
</tt><tt>hello</tt><tt><br>
</tt><tt><br>
</tt><tt>(node1)3> flush().</tt><tt><br>
</tt><tt>Shell got hello</tt><tt><br>
</tt><tt>ok</tt><tt><br>
</tt><br>
<br>
Now on node1 shell register with the name again, it removes the
existing registration:<br>
<br>
<tt>(node1)4> gproc:reg({n, g, abcde}).</tt><tt><br>
</tt><tt>** exception error: bad argument</tt><tt><br>
</tt><tt> in function gproc:reg/1</tt><tt><br>
</tt><tt> called as gproc:reg({n,g,abcde})</tt><tt><br>
</tt><tt>(node1)5> gproc:where({n, g, abcde}).</tt><tt><br>
</tt><tt>undefined</tt><br>
<br>
<br>
But on node2 the shell still gets <8049.229.0>:<br>
<br>
<tt>(node2)3> gproc:where({n, g, abcde}).</tt><tt><br>
</tt><tt><8049.229.0></tt><br>
<br>
<br>
And sending message from node2 shell to 'abcde' still works
'fine', but the node1 shell doesn't get any message:<br>
<tt><br>
</tt><tt>(node2)4> gproc:send({n, g, abcde}, hello).</tt><tt><br>
</tt><tt>hello</tt><tt><br>
</tt><tt><br>
</tt><tt>(node1)6> flush().</tt><tt><br>
</tt><tt>ok</tt><tt><br>
</tt><br>
<br>
Now if I register node1 shell as {n, g, abcde} again, everything
works fine again:<br>
<br>
<tt>(node1)7> gproc:reg({n, g, abcde}).</tt><tt><br>
</tt><tt>true</tt><tt><br>
</tt><tt><br>
</tt><tt>(node2)5> gproc:where({n, g, abcde}).</tt><tt><br>
</tt><tt><8049.268.0></tt><tt><br>
</tt><tt>(node2)6> gproc:send({n, g, abcde}, hello).</tt><tt><br>
</tt><tt>hello</tt><tt><br>
</tt><tt><br>
</tt><tt>(node1) 8> flush().</tt><tt><br>
</tt><tt>Shell got hello</tt><tt><br>
</tt><tt>ok</tt><br>
<br>
<br>
This doesn't look right to me.<br>
1) When registering with a name already registered, why doesn't
gproc return something like {error, already_registered}?<br>
2) After the registration is removed, why does a remove node
still sees the non-existent registration?<br>
<br>
<br>
Thanks<br>
Khitai </div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
</blockquote>
<br>
</body>
</html>