Erlang Mailing Lists

Author Message

<  Erlang patches mailing list  ~  driver_entry init() return value ignored

vance
Posted: Fri Aug 10, 2007 10:23 pm Reply with quote
User Joined: 27 Apr 2005 Posts: 129 Location: Toronto, Ontario, Canada
The driver_entry structure is a C struct that all erlang drivers
define. It contains entry points for the erlang driver that are
called by the erlang emulator when erlang code accesses the driver.

The first of the function pointers is init() which is called at
system startup for sdtaically linked drivers and after loading
for dynamically loaded drivers. The init() function is documented
in erts-5.5.5/doc/html/driver_entry.html as:

int init(void)

This is called directly after the driver has been loaded by
erl_ddll:load_driver/2. (Actually when the driver is added
to the driver list.) The driver should return 0, or if the
driver can't initialize, -1.

In the R11B-5 implementation init() is actually defined as returning
void, the return value of the driver's init() callback is ignored.

I discovered this during development of a linked in driver which
was failing to initialize due to library path problems. Instead
of erl_ddll:load_driver/1 failing with an appropriate error it was
succeeding and the problem wasn't recognized until much later in
the startup process. This violates the principal of least astonishment.

The attached patch seems to resolve the problem and I have tested
it with my dynamically linked drivers. I have not considered what
impact this change would have on a staticaly linked driver failing
however.

-Vance



Post recived from mailinglist
View user's profile Send private message Send e-mail

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum