[erlang-patches] Small fix to erl_interface legacy receive function

Göran Larsson A <>
Wed Apr 27 03:20:40 CEST 2011


Hi Björn-Egil,

It turns out it was more my misunderstanding of how GIT works (used to Subversion and ClearCase) that was the problem than anything else. So, after some fiddling I finaly managed to create and commit my own branch. Hope this one will work, as it is the first time I ever commited anything in GIT;

git fetch git://github.com/galarsson/otp.git erl_do_receive_msg

/Göran

-----Original Message-----
From:  [mailto:] On Behalf Of Björn-Egil Dahlberg
Sent: Tuesday, April 26, 2011 9:20 PM
To: 
Subject: Re: [erlang-patches] Small fix to erl_interface legacy receive function

Hi Göran,

Thanks for pointing out this issue. I will have a look at the fix and make a git branch for it.

Regards,
Björn-Egil Dahlberg
Erlang/OTP, Ericsson AB

On 2011-04-26 06:59, Göran Larsson A wrote:
> When I was playing with the 'erl_interface' in an attempt to write a C++ wrapper for it, I used the 'cnode.c' test case from the 'erl_eterm_SUITE' as a base. Yes I know that the interface it uses is legacy, but it was an easy piece of code to start with.
>
> The problem I got into was when trying to process rpc calls from an erlang node. The function 'erl_xreceive_msg' returned garbage in the 'to' and 'to_name' members of the message. The reason for that was found in the 'erl_do_receive_msg' function. When no 'pid' is provided by the sender, like when doing rpc calls as those uses registered name sends, it doesn't initialize the 'to' member and also the 'to_name' member is copied by the function.
>
> The solution is a small modification to the 'erl_do_receive_msg' function in 'legacy/erl_connect.c' from line 294 (erl_interface-3.7.3). Unfortunatly I'm not able to use GIT due to firewall issues in China where I am currently. So have to provide the modified code snippet the old fashioned way!
>
> ---erl_connect.c------------------------------------------------------
> -- static int erl_do_receive_msg(int fd, ei_x_buff* x, ErlMessage* 
> emsg) {
>      ...
>      if (msg.from.node[0] != '\0')
>          emsg->from = erl_mk_pid(msg.from.node, msg.from.num, msg.from.serial, msg.from.creation);
>      else
>          emsg->from = NULL; /* Uninitialized pointers are no fun */
>      if (msg.to.node[0] != '\0')
>          emsg->to = erl_mk_pid(msg.to.node, msg.to.num, msg.to.serial, msg.to.creation);
>      else
>          emsg->to = NULL; /* Uninitialized pointers are no fun */
>      memcpy(emsg->to_name, msg.toname, MAXATOMLEN+1); /* We might be referred by registered name rather than by pid */
>      return r;
> }
> ----------------------------------------------------------------------
> --
>
> Regards,
> Göran Larsson, Ericsson AB
> _______________________________________________
> erlang-patches mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-patches
>

_______________________________________________
erlang-patches mailing list

http://erlang.org/mailman/listinfo/erlang-patches


More information about the erlang-patches mailing list