Re: Adding/removing handles to the multi_handle produces unexpected result of curl_multi_perform
Date: Fri, 27 Sep 2019 23:49:07 +0300
Hello Patrick,
пт, 27 сент. 2019 г. в 18:25, Patrick Schlangen via curl-library <
curl-library_at_cool.haxx.se>:
> >
> > curl_multi_add_handle(multi_handle, easy_handle);
>
> can you log and check the return code of the curl_multi_add_handle calls?
> Maybe they fail for some reason. In general, I’d recommend to check all the
> return codes of every curl call.
>
>
My actual code checks return codes of all curl_* calls and will report
failures. I removed all error handling code from the pastebin example to
make it shorter. Actually that part of code looks like:
auto result = curl_multi_add_handle(multi_handle, easy_handle);
if(result != CURLM_OK)
{
throw std::runtime_error(std::string("Error adding curl sub handle to
multi handle: ").append(curl_multi_strerror(result)));
}
Also I’d move the last curl_multi_perform call in line 53 (pastebin) before
> line 23 (so the order will be perform -> wait, as in the example [1]), to
> fix the following:
> * Currently you’re calling curl_multi_perform after every
> curl_multi_info_read, even if you didn’t add any new handles or didn’t wait
> for more I/O.
> * You’re also never calling curl_multi_perform again if none of the
> transfers has any messages/informationals available (some might be still
> active waiting for I/O, for example).
>
> Oh, i need to split that loop to make that kind of errors more obvious.
On the other hand, i just moved curl_multi_perform from line 23 to a new
line betwen 54 and 55, so now it is called unconditionally at the end of
the loop and before curl_multi_wait in the beginning of the loop, which is
completely equal to yor proposal. Even with that configuration the problem
is still here: last (or single) easy_handle returns error, i remove it from
the multi_handle and then create new easy_handle and add it to the multi
handle. curl_multi_perform at the end of the loop still sets
running_handles to 0 and loop exits, while i expect running_handles to be
1, as i just added new unprocessed easy_handle.
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2019-09-27