curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_multi_perform callback busyloop

From: Sergey Naumov <sknaumov_at_gmail.com>
Date: Fri, 2 Dec 2016 17:42:56 +0300

Hi Daniel.

Thanks for your response.

I found out today what was the reason here: I had to rerun
curl_multi_fdset() just after curl_multi_perform() in my callback to check
whether we need to listen to different set of events.
But I still have a couple of questions:

1. Is it safe to assume that libcurl uses only 1 sockfd for HTTP? It seems
to be true, just want to double-check.
2. For some reason when I'm emulating curl_easy_perform by
curl_multi_perform, the following option no longer works:
    curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1);
    ...
    qh_curl_easy_perform(curl, &http_code); // <- emulated by multi-perform
    ...
    curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, &sockfd); // <-- sockfd
== -1 if emulation with multi-perform enabled

It looks like CONNECT_ONLY option actually works and nothing is done except
of connection establishmend / reusage, but sockfd is not available.

Right now I'm testing with curl-7.47.1, but planning to use any library
since 7.25.0. Is there some way to make multi-perform not to close
connection, or is it a bug and better just to force easy mode in this case?

Thanks,
Sergey.

2016-12-02 14:41 GMT+03:00 Daniel Stenberg <daniel_at_haxx.se>:

> On Wed, 30 Nov 2016, Sergey Naumov wrote:
>
> I use curl_multi_perform, curl_multi_timeout and curl_multi_fdset in the
>> main loop and curl_multi_perform in callback that is called when there is
>> an event on CURL fd.
>>
>
> Wait, what? You call curl_multi_perform() from within which callback? I
> hope that isn't a libcurl callback, because you should never call libcurl
> recursively like that.
>
> --
>
> / daniel.haxx.se
> -------------------------------------------------------------------
> List admin: https://cool.haxx.se/list/listinfo/curl-library
> Etiquette: https://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-12-02