curl-library
Re: pthread_cancel while in curl_easy_perform
Date: Wed, 30 Jan 2013 09:22:19 -0500
Daniel Stenberg wrote:
> On Tue, 29 Jan 2013, Andrew Strohman wrote:
>
>>> http://curl.haxx.se/docs/faq.html#How_do_I_stop_an_ongoing_transfe
>>
>> Thanks for the reply. Does your statement also apply to the multi
>> interface? The way the faq is worded gives me hope that I can safely do
>> pthread_cancel if I'm using the multi interface. Is that right?
>
> Nope. Forget about pthread_cancel (or any other thread-killing function),
> that's not the tool you want for this task.
>
> The standard way to stop a transfer with the multi interface is what is
> described in that FAQ entry: "If you're using the multi interface, you can
> also stop a transfer by removing the particular easy handle from the multi
> stack at any moment you think the transfer is done."
>
This operation too must be done in the thread that is running the multi, you
can't remove the handle in another thread. One way to do this would be to
add the read end of a fifo to the select() statement. Another thread which
wants to cause a transfer to stop could write a stop code to the fifo. The
multi processing thread would see the fifo become readable and could get and
act on the passed code. There may be a Better Way...
It says "[when] you think the transfer is done." Does that mean there's
going to be trouble if one removes and cleans up an an easy handle at an
arbitrary point in a transfer (aside from possibly being rude to the server
at the other end?) Will resources be released? Would it be correct to add
"or when you wish to abort the transfer."?
- Rich
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-01-30