[erlang-questions] Process not receiving first message when using driver_send_term()?
Yousef A
hasbean@REDACTED
Mon Feb 18 09:07:20 CET 2013
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)
This is the driver entry:
static ErlDrvEntry lua_driver_entry = {
NULL, /* init */
start, /* startup */
stop, /* shutdown */
NULL, /* output */
NULL, /* ready_input */
NULL, /* ready_output */
"liberlua", /* the name of the driver */
NULL, /* finish */
NULL, /* handle */
NULL, /* control */
NULL, /* timeout */
process, /* outputv */
NULL, /* ready_async */
NULL, /* flush */
NULL, /* call */
NULL, /* event */
ERL_DRV_EXTENDED_MARKER, /* ERL_DRV_EXTENDED_MARKER */
ERL_DRV_EXTENDED_MAJOR_VERSION, /* ERL_DRV_EXTENDED_MAJOR_VERSION */
ERL_DRV_EXTENDED_MINOR_VERSION, /* ERL_DRV_EXTENDED_MINOR_VERSION */
ERL_DRV_FLAG_USE_PORT_LOCKING /* ERL_DRV_FLAGs */
};
And the process function:
static void process(ErlDrvData handle, ErlIOVec *ev)
{
lua_drv_t *driver_data = (lua_drv_t*) handle;
ErlDrvTermData spec[] = {
ERL_DRV_ATOM, driver_mk_atom((char*) "testing")
};
//send 3 requests and see how many the process receives.
driver_send_term(driver_data->port, driver_caller(driver_data->port),
spec, sizeof(spec) / sizeof(spec[0]));
driver_send_term(driver_data->port, driver_caller(driver_data->port),
spec, sizeof(spec) / sizeof(spec[0]));
driver_send_term(driver_data->port, driver_caller(driver_data->port),
spec, sizeof(spec) / sizeof(spec[0]));
}
And for Erlang, it's a gen_server:
handle_info(Info, State) ->
io:format("~n~n========game sent bogus msg============~n ~p ~n~n", [Info]),
{noreply, State}.
When run, this is what the Erlang process prints out:
========game sent bogus msg============
testing
========game sent bogus msg============
testing
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.
Thanks!
--Yousef
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130218/5689002e/attachment.htm>
More information about the erlang-questions
mailing list