curl-library
Re: Timeout behavior with multiple addresses
Date: Sat, 18 Dec 2010 14:56:42 -0800
On Thu, Dec 16, 2010 at 3:44 PM, Michael Fischer <michael_at_dynamine.net> wrote:
> Suppose I initiate a connection to a host that resolves to more than
> one address (e.g. 10.0.0.1 and 10.0.0.2), and I set CURLOPT_TIMEOUT_MS
> to 10 seconds. (I don't currently set CURLOPT_CONNECTTIMEOUT*.)
>
> What is the expected behavior if 10.0.0.1 does not respond within 10
> seconds? Will curl attempt to connect to 10.0.0.2 after the timeout
> expires? If not, what is the recommended practice for this scenario
> such that I can still have a timeout but ensure each host is tried?
I dug a bit deeper into the code and found this in Curl_connecthost():
/* Max time for each address */
num_addr = Curl_num_addresses(remotehost->addr);
timeout_per_addr = timeout_ms / num_addr;
if(data->state.used_interface == Curl_if_multi)
/* don't hang when doing multi */
timeout_per_addr = 0;
So, it appears that if you are using the multi interface, but set
CURLOPT_*TIMEOUT to a value shorter than the OS default, the timeout
will expire before the next address in the list is attempted.
Any plans to remediate this?
--Michael
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-12-18