Driver init failure not detected

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Driver init failure not detected

Sean Hinde-2
Hi,

If I have a driver with an init function defined in the driver_entry e.g

static struct driver_entry oci_driver_entry = {
    oci_init,
    oci_start,
    oci_stop,
...
}

and the oci_init function returns -1:

static int oci_init(void)
{
return -1
}

I would expect that the erl_ddll:driver_load/2 call would fail. But it
returns 'ok'

This is not what the documentation says..

Am I doing something wrong here or is it a bug?

Thanks,
Sean



NOTICE AND DISCLAIMER:
This email (including attachments) is confidential.  If you have received
this email in error please notify the sender immediately and delete this
email from your system without copying or disseminating it or placing any
reliance upon its contents.  We cannot accept liability for any breaches of
confidence arising through use of email.  Any opinions expressed in this
email (including attachments) are those of the author and do not necessarily
reflect our opinions.  We will not accept responsibility for any commitments
made by our employees outside the scope of our business.  We do not warrant
the accuracy or completeness of such information.




Reply | Threaded
Open this post in threaded view
|

Driver init failure not detected

Peter H|gfeldt

The init function of struct driver_entry is not used for dynamic
drivers. See erl_ddll(3) for the details.

/Peter


On Mon, 29 Oct 2001, Sean Hinde wrote:

> Hi,
>
> If I have a driver with an init function defined in the driver_entry e.g
>
> static struct driver_entry oci_driver_entry = {
>     oci_init,
>     oci_start,
>     oci_stop,
> ...
> }
>
> and the oci_init function returns -1:
>
> static int oci_init(void)
> {
> return -1
> }
>
> I would expect that the erl_ddll:driver_load/2 call would fail. But it
> returns 'ok'
>
> This is not what the documentation says..
>
> Am I doing something wrong here or is it a bug?
>
> Thanks,
> Sean
>
>
>
> NOTICE AND DISCLAIMER:
> This email (including attachments) is confidential.  If you have received
> this email in error please notify the sender immediately and delete this
> email from your system without copying or disseminating it or placing any
> reliance upon its contents.  We cannot accept liability for any breaches of
> confidence arising through use of email.  Any opinions expressed in this
> email (including attachments) are those of the author and do not necessarily
> reflect our opinions.  We will not accept responsibility for any commitments
> made by our employees outside the scope of our business.  We do not warrant
> the accuracy or completeness of such information.
>
>



Reply | Threaded
Open this post in threaded view
|

Driver init failure not detected

Jakob Praher
At 22:27 2001-10-29 +0100, you wrote:

>The init function of struct driver_entry is not used for dynamic
>drivers. See erl_ddll(3) for the details.
>
>/Peter

This is almost right, and the driver_entry.html is wrong (it's fixed now).
There are pecularities in erl_ddll.html though, the handle is not used, and
you don't need a null_func, NULL is fine to put in the driver_entry (from
R8), etc. This will also be fixed.

The truth is that init is indeed called when a dynamic driver is loaded (it
is done so in the add_driver_entry function in the emulator). But the
return code from init is ignored. My feeling about this is that this is
wrong, and that the return code should be checked, and the emulator (or
erl_ddll) should unload the driver if init returns -1. But for now it
doesn't. You'll have to set some error variable and check this later on.

/Jakob