cURL / Mailing Lists / curl-library / Single Mail

curl-library

curl_multi_wait changes timeout to 0 and returns immediately

From: Alex Lyakas <alex_at_zadarastorage.com>
Date: Tue, 16 Dec 2014 00:25:17 +0200

Greetings curl developers,

I am trying to use curl_multi_wait API in conjunction with
curl_multi_perform. I am doing a test that sends a single HTTPS
request to Amason S3 service. I am using libcurl version 7.35 compiled
from the source on Linux (kernel 3.8.13). I always specify one
"extra_fd", which most of the time is not readable, and a timeout of
30,000 msec.

What I see is that curl_multi_wait appears to always change this value
to 0 ms, and as a result it's poll() call returns immediately. This
results in a busy loop in the calling thread. Is this something
expected?

As an experiment, I tried to specify timeout=-1 to the curl_multi_wait
API. In this case, the timeout value is not overridden, and everything
works as expected. However, I am bit worried to use timeout=-1,
because as I learned from email thread
"curl_multi_wait returns immediately when using bandwidth limit"
in http://curl.haxx.se/mail/lib-2014-05/0224.html,
in some cases, the code may decide that the state of the SessionHandle
is not appropriate for returning any socket. In that case, it may
happen that the only socket that libcurl will wait on, will be my
extra socket. But since I specify -1 as a timeout, this wait will
never be awaken, unless I arrange some external mechanism to make my
socket readable from time to time.

Am I missing something? What the caller is expected to do if
curl_multi_wait returns immediately? I see that in curl_easy_perform,
there is some code which sleeps if that happens (depending on the
number of times that it happened). Is this the recommended approach?

Or should I drop the curl_multi_wait approach and try to use the
curl_multi_socket_action API?

Thanks!
Alex.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-12-15