<div dir="ltr">Please ignore this. Apparently, lua.erl has a "receive" part whenever I run lua:func() which explains why I keep missing the first one, duh.<div><br></div><div><br><br><div class="gmail_quote">On Mon, Feb 18, 2013 at 11:07 AM, Yousef A <span dir="ltr"><<a href="mailto:hasbean@gmail.com" target="_blank">hasbean@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I've been trying to add features to liberlua, but I ran into this wall. I'm running a port_command on Erlang and receiving it with outputv in the driver, but not all driver_send_terms are received by the calling process. I'm using R15B03 (erts-5.9.3.1)</div>
<div><br></div><div>This is the driver entry:</div><div><br></div><div><div><font face="courier new, monospace">static ErlDrvEntry lua_driver_entry = {</font></div><div><font face="courier new, monospace"><br></font></div>
<div><font face="courier new, monospace"> NULL, /* init */</font></div><div><font face="courier new, monospace"> start, /* startup */</font></div><div><font face="courier new, monospace"> stop, /* shutdown */</font></div>
<div><font face="courier new, monospace"> NULL, /* output */</font></div><div><font face="courier new, monospace"> NULL, /* ready_input */</font></div><div><font face="courier new, monospace"> NULL, /* ready_output */</font></div>
<div><font face="courier new, monospace"> "liberlua", /* the name of the driver */</font></div><div><font face="courier new, monospace"> NULL, /* finish */</font></div>
<div><font face="courier new, monospace"> NULL, /* handle */</font></div><div><font face="courier new, monospace"> NULL, /* control */</font></div><div><font face="courier new, monospace"> NULL, /* timeout */</font></div>
<div><font face="courier new, monospace"> process, /* outputv */</font></div><div><font face="courier new, monospace"> NULL, /* ready_async */</font></div><div><font face="courier new, monospace"> NULL, /* flush */</font></div>
<div><font face="courier new, monospace"> NULL, /* call */</font></div><div><font face="courier new, monospace"> NULL, /* event */</font></div><div><font face="courier new, monospace"> ERL_DRV_EXTENDED_MARKER, /* ERL_DRV_EXTENDED_MARKER */</font></div>
<div><font face="courier new, monospace"> ERL_DRV_EXTENDED_MAJOR_VERSION, /* ERL_DRV_EXTENDED_MAJOR_VERSION */</font></div><div><font face="courier new, monospace"> ERL_DRV_EXTENDED_MINOR_VERSION, /* ERL_DRV_EXTENDED_MINOR_VERSION */</font></div>
<div><font face="courier new, monospace"> ERL_DRV_FLAG_USE_PORT_LOCKING /* ERL_DRV_FLAGs */</font></div><div><font face="courier new, monospace">};</font></div></div><div><br></div><div>And the process function:</div>
<div><br></div><div><div><font face="courier new, monospace">static void process(ErlDrvData handle, ErlIOVec *ev)</font></div><div><font face="courier new, monospace">{</font></div><div><font face="courier new, monospace"> lua_drv_t *driver_data = (lua_drv_t*) handle;</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"> ErlDrvTermData spec[] = {</font></div><div><font face="courier new, monospace"> <span style="white-space:pre-wrap"> </span>ERL_DRV_ATOM, driver_mk_atom((char*) "testing")</font></div>
<div><font face="courier new, monospace"> <span style="white-space:pre-wrap"> </span>};</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"><br>
</font></div><div><span style="font-family:'courier new',monospace"> //send 3 requests and see how many the process receives.</span></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"> driver_send_term(driver_data->port, driver_caller(driver_data->port), spec, sizeof(spec) / sizeof(spec[0]));</font></div>
<div><font face="courier new, monospace"> driver_send_term(driver_data->port, driver_caller(driver_data->port), spec, sizeof(spec) / sizeof(spec[0]));</font></div><div><font face="courier new, monospace"> driver_send_term(driver_data->port, driver_caller(driver_data->port), spec, sizeof(spec) / sizeof(spec[0]));</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">}</font></div></div><div><br></div><div>And for Erlang, it's a gen_server:</div><div><br></div><div><div><font face="courier new, monospace">handle_info(Info, State) -></font></div>
<div><font face="courier new, monospace"><span style="white-space:pre-wrap"> </span>io:format("~n~n========game sent bogus msg============~n ~p ~n~n", [Info]),</font></div><div><font face="courier new, monospace"><span style="white-space:pre-wrap"> </span>{noreply, State}.</font></div>
</div><div><font face="courier new, monospace"><br></font></div><div><br></div><div>When run, this is what the Erlang process prints out:</div><div><br></div><div><div><font face="courier new, monospace">========game sent bogus msg============</font></div>
<div><font face="courier new, monospace"> </font><span style="font-family:'courier new',monospace">testing</span><font face="courier new, monospace"> </font></div><div><font face="courier new, monospace"><br></font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">========game sent bogus msg============</font></div><div><font face="courier new, monospace"> </font><span style="font-family:'courier new',monospace">testing</span><font face="courier new, monospace"> </font></div>
</div><div><br></div><div><br></div><div><br></div><div><br></div>And that's it, only 2 messages when 3 driver_send_term() requests are called. I must have missed something, because I don't see anyone else complaining about this problem.<div>
<br></div><div>Thanks!</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>--Yousef<br><div><br></div><div><br></div></div></font></span></div>
</blockquote></div><br></div></div>