Пример #1
0
static int erl_do_receive_msg(int fd, ei_x_buff* x, ErlMessage* emsg)
{
    erlang_msg msg;

    int r;
    msg.from.node[0] = msg.to.node[0] = msg.toname[0] = '\0';
    r = ei_do_receive_msg(fd, 0, &msg, x, 0);

    if (r == ERL_MSG) {
	int index = 0;
	emsg->type = msg.msgtype;

	/*
	  We can't call ei_decode_term for cases where there are no
	  data following the type information. If there are other
	  types added later where there are data this case has to be
	  extended.
	*/

	switch (msg.msgtype) {
	case ERL_SEND:
	case ERL_REG_SEND:
	case ERL_EXIT:
	case ERL_EXIT2:
	  if (ei_decode_term(x->buff, &index, &emsg->msg) < 0)
	    r = ERL_ERROR;
	  break;
	default:
	  emsg->msg = NULL;	/* Not needed but may avoid problems for unsafe caller  */
	  break;
	}
    } else
	emsg->msg = NULL;
    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;
    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;
    strcpy(emsg->to_name, msg.toname);
    return r;
}
Пример #2
0
int ei_xreceive_msg_tmo(int fd, erlang_msg *msg, ei_x_buff *x, unsigned ms)
{
    return ei_do_receive_msg(fd, 0, msg, x, ms);
}
Пример #3
0
int ei_xreceive_msg(int fd, erlang_msg *msg, ei_x_buff *x)
{
    return ei_do_receive_msg(fd, 0, msg, x, 0);
}