[erlang-questions] driver_async() marks driver as permanent?

Paul Fisher <>
Sat Apr 5 03:29:04 CEST 2008

On Fri, 2008-04-04 at 09:41 -0500, Paul Fisher wrote:
> Does using driver_async() from within a linked-in driver mark the driver
> as permanent automatically?  I am seeing an {error, permanent} out of
> erl_ddll:unload_driver/1 even after all of the processes which called
> open_port/2 have exited, and therefore all of the port instances using
> the driver have stopped.
> If this is done automatically, is there a way to "unmark" it, so that I
> can still unload the driver?

Answering my own question again...  I got some time this evening to look
into this, and apparently the answer is yes.  This little tidbit in
erts/emulator/beam/erl_async.c:async_add(), line 139 (R12B-1):

    /* XXX:PaN Is this still necessary when ports lock drivers? */
    if (is_internal_port(a->port)) {
	/* make sure the driver will stay around */

which eventually winds its way down to this in erl_bif_ddll.c, line 1109

    dh->procs = NULL;
    dh->status = ERL_DE_PERMANENT;

and there is not any place that removes that status value, that I can
find on brief inspection. (Basically only initialization/reload code
sets this field.)

So is the comment in async_add() proper and this could be removed?  (I'd
appreciate some guidance on this as this is the first time i've mucked
around the runtime code and just don't have the background yet to make
informed decisions.)


More information about the erlang-questions mailing list