[erlang-bugs] erl_driver documentation confusing

Sverker Eriksson sverker@REDACTED
Thu Jul 17 14:51:05 CEST 2008


Hi Paul

I agree the example is a bit misleading. I guess this is what you want 
to do:

unsigned key = (unsigned) myPort;

:

r = driver_async(myPort, &key, myData, myFunc);


Using the port identifier is just a way to select a "random" thread. And 
it's enough to initialize 'key' once, in the start function of 
erl_drv_entry for example.

The only reason for driver_async to assign to *key (that I can see) is 
that, after the call to driver_async(), *key will uniquely identify the 
used thread. I don't see how that would be very useful though.

I will change the documentation according to my example above, unless 
you have any other suggestion.

/Sverker, Erlang/OTP Ericsson


Paul Mineiro wrote:
> the documentation for erl_driver says that to ensure that the same thread
> is used for all calls to your driver you should do:
>
> r = driver_async(myPort, (unsigned int*)&myPort, myData, myFunc);
>
> well this caused me lots of troubles because inside the implementation to
> driver_async in erts/emulator/beam/erl_async.c there is a line
>
> *key = qix;
>
> where key is the 2nd argument to driver_async.  this caused some
> segmentation faults in my code until i realized this was happening (since
> I continued to use myPort as a valid port).
>
> -- p
>
> p.z. is there a reason *key is assigned at all?
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-bugs
>   




More information about the erlang-bugs mailing list