curl-library
Changes to connection timeout policy when multiple DNS records are present
Date: Mon, 10 Nov 2014 17:03:29 -0800
Hi all,
After doing some testing with libcurl lately I have noticed curl's connect
behavior on timeouts has changed sometime between 7.22 and 7.39. I have
tested 3 different versions using the easy interface and all 3 have
different behavior. In all tests, I have set a timeout of 10 seconds and
attempt to fetch www.google.com:45, which of course is not reachable.
7.22:
* About to connect() to www.google.com port 45 (#0)
* Trying 74.125.239.52... * Timeout
* Trying 74.125.239.51... * Timeout
* Trying 74.125.239.50... * Timeout
* Trying 74.125.239.49... * Timeout
* Trying 74.125.239.48... * Timeout
* connect() timed out!
* Closing connection #0
In this version, curl tries to connect to each IP and declares it as timed
out it there was no response in 2 seconds. If you call curl_easy_get_info
with CURLINFO_PRIMARY_IP after the requests have timed out, it will return
you the last IP that was attempted (74.125.239.48).
7.36:
* Rebuilt URL to: www.google.com:45/
* Hostname was NOT found in DNS cache
* Trying 74.125.239.51...
* After 4998ms connect time, move on!
* connect to 74.125.239.51 port 45 failed: Connection timed out
* Trying 74.125.239.50...
* After 2499ms connect time, move on!
* connect to 74.125.239.50 port 45 failed: Connection timed out
* Trying 74.125.239.49...
* After 1249ms connect time, move on!
* connect to 74.125.239.49 port 45 failed: Connection timed out
* Trying 74.125.239.48...
* After 623ms connect time, move on!
* connect to 74.125.239.48 port 45 failed: Connection timed out
* Trying 74.125.239.52...
* After 312ms connect time, move on!
* connect to 74.125.239.52 port 45 failed: Connection timed out
* Failed to connect to www.google.com port 45: Connection timed out
* Closing connection 0
Now curl seems to allocate half its time to the first connection, half of
that time to the second, and so on. CURLINFO_PRIMARY_IP now returns the
empty string after these fetches.
7.39:
* Rebuilt URL to: www.google.com:45/
* Hostname was NOT found in DNS cache
* Trying 74.125.239.49...
* After 4999ms connect time, move on!
* connect to 74.125.239.49 port 45 failed: Connection timed out
* Trying 74.125.239.48...
* After 2396ms connect time, move on!
* connect to 74.125.239.48 port 45 failed: Connection timed out
* Trying 74.125.239.52...
* After 1197ms connect time, move on!
* connect to 74.125.239.52 port 45 failed: Connection timed out
* Trying 74.125.239.51...
* After 196ms connect time, move on!
* connect to 74.125.239.51 port 45 failed: Connection timed out
* Trying 74.125.239.50...
* Connection timed out after 10000 milliseconds
* Closing connection 0
The strategy here seems mostly the same as in 7.36, except the values don't
make as much sense. If you add up the times it spent on each individual
connection, you end up well short of 10000 ms, even though the wallclock
time of the program is very close to 10 seconds. CURLINFO_PRIMARY_IP is
also missing here.
So I have a few questions:
1) When did the retry behavior change between 7.22 and 7.36? I don't see
anything in the changelog relating to retries to timeouts on connections.
2) Was it intentional to remove CURLINFO_PRIMARY_IP when a connection was
not established? I was relying on this value before as long as the DNS
resolution was successful and now it is mysteriously not there.
3) What happened between 7.36 and 7.39 to make the timings "strange" in
the current version?
Thanks,
Ryan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-11-11