Re: Question about curl_multi_remove_handle()
Date: Fri, 9 Dec 2016 17:01:01 +0100
Hi & thanks,
Well, when I read your replies, I realize that I probably didn't
describe the situation correct. Sorry for the confusion.
All threads will use their own multi handle, so the task switch I
mentioned is probably not a concern.
Let me rephrase the question like this:
Are those callback functions triggered by the call to curl_multi_perform()?
If so, did I understand you correct that curl_multi_perform() won't
return until all callback functions have been completed (they are
running synchronously in the same thread as curl_multi_perform())?
If so, I feel confident that I will not manage to remove any handle
until the callback functions have been completed. The next time they
could have been invoked, after calling curl_multi_perform(), the multi
handle won't contain those easy handles that were removed. Hence the
callback functions will not be called, so the user data argument that
this time would have been dangling pointers are of no concern. Does this
make sense to you?
Maybe I was worried that the callback functions would have been executed
in separate threads, making them asynchronous to the
curl_multi_perform() call. That situation would have been more difficult
On 12/04/2016 01:02 AM, Daniel Stenberg wrote:
> On Tue, 29 Nov 2016, Andreas Hollaus wrote:
>> I've read that calling curl_multi_remove_handle() is the correct way
>> to stop an ongoing transfer. Still, I'm curious about the callback
>> functions configured for the easy handle (CURLOPT_HEADERFUNCTION &
>> Can they still be triggered after the handle was removed, in the rare
>> case that some data was previously fetched to the buffer? I do
>> understand that no more data will be fetched to the buffer after the
>> handle is removed.
> I'm pretty sure there can at least not be any more data. There can
> potentially be more headers so that callback can probably still get
> called. I don't recall off the top of my head if we've done anything
> to prevent that.
>> I guess that the callback functions are triggered by the
>> curl_multi_perform() call, right? What if there's a task switch
>> before the callback function is triggered so that another thread
>> could call curl_multi_remove_handle(). Would that still stop the
>> waiting callback function from being called?
> I don't think libcurl can return back from a function call without
> delivering received data to the data callback.
List admin: https://cool.haxx.se/list/listinfo/curl-library
Received on 2016-12-09