[erlang-bugs] ei_reg_send is destructive to the erlang node's pid

Paul Guyot pguyot@REDACTED
Fri Oct 17 10:41:59 CEST 2008


Hello,

I noticed that ei_reg_send and ei_reg_send_tmo are destructive of the  
node's pid:

     erlang_pid *self = ei_self(ec);
     self->num = fd;

(and so is ei_rpc_to)

The same problem can be found in the code snipet in  
ei_send_reg_encoded's documentation:

> A suitable erlang_pid can be constructed from the ei_cnode  
> structure by the following example code:
>
>           ei_cnode ec;
>           erlang_pid *self;
>           int fd; /* the connection fd */
>           ...
>           self = ei_self(&ec);
>           self->num = fd;


This means that two calls to ei_self won't return the same value, and  
this might be a problem for pids sent to a node and then received  
back and compared, especially if several fds are passed to  
ei_reg_send to send messages to several distant nodes (and therefore  
several connection fds).

I am actually confused by the comment. Why such a pid is suitable and  
the original node's pid (<nodename.0.0.0>) unsuitable?

Paul




More information about the erlang-bugs mailing list