[erlang-questions] Fw: driver_async invoke leads to a segmentation fault
Tony Rogvall
tony@REDACTED
Wed Dec 27 12:30:43 CET 2006
Hi!
Have you used/seen the async_ready callback. The async_ready is
called when the call is completed, and
is called in the main thread. Here is the place to signal back to the
Erlang application making the call/cast
that the call is completed.
Also the way you do the call, you must make sure that the function
callTextToSpeech is thread safe, since you
may have multiple instances running at the same time (at least from
what I can see in the code fragement).
You can synchronize either:
a) Use the same key argument (not NULL) to make sure the same thread
is used for the calll
b) Do not issue an other call before async_ready is called.
c) Make everything thread safe.
Regards
/Tony
On 27 dec 2006, at 03.48, Niranjan Gunasekera wrote:
> Can anybody help, please
>
>
> Thanks
> Niranjan Gunasekera
> ----- Original Message -----
> From: Niranjan Gunasekera
> To: erlang-questions@REDACTED
> Sent: Friday, December 22, 2006 9:06 AM
> Subject: [erlang-questions] driver_async invoke leads to a
> segmentation fault
>
> Hi all,
> I’m using erlang driver_async to invoke a function
> asynchronously. First reference to the function ‘driver_async’
> works fine. But next reference to the same call leads to a
> segmentation fault. I’m using erlang release R11B-2. Same code
> works fine with erlang release R10B-10. Is it a problem with erlang
> release?
>
> Is it a problem with coding?
>
> static int control(ErlDrvData drv_data, unsigned int command, char
> *buf, int len, char **rbuf, int rlen)
> {
> --------
> --------
> DriverData *dd = (DriverData *) drv_data;
> set_port_control_flags(dd->port,
> PORT_CONTROL_FLAG_BINARY);
> ThreadData *threadData;
> if((threadData = (ThreadData *) driver_alloc(sizeof
> (ThreadData))) == NULL) {
> error = 1;
> }
> else {
> error = 0;
> memset(threadData, 0, sizeof(threadData));
> if((threadData->input = (char *)
> driver_alloc(len + 1)) == NULL) {
> free(threadData);
> error = 1;
> }
> else {
> ---------
> ---------
> driver_async(dd->port, NULL,
> callTextToSpeech, (void *)threadData, freeThreadData); //first
> call to this function works fine
> }
> }
>
> }
> if (error)
> gen_error_reply(rbuf, rlen, &rindex,
> "driver_alloc_failiure", 0);
> else
> gen_ok_reply(rbuf, rlen, &rindex);
> }
>
> Thanks
> Niranjan Gunasekera
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20061227/2c6a32e3/attachment.htm>
More information about the erlang-questions
mailing list