Hello, I use libcurl in a performance-sensitive application, where timeout values need to be well-adjusted. An issue has arisen with some domain names pointing to a round-robin of IP addresses. libcurl tries each IP address sequentially and divides the timeout value between all of them. Let's say that I set a connection timeout of 2 seconds, which seems plenty reasonable for normally responsive hosts. Let's say that I hit a host pointing to 10 IP addresses. 2s / 10 = 200 ms, so despite my reasonable 2 seconds timeout, libcurl will try to connect to every IP with a timeout of only 200 ms. If the host is on another continent, even with good network connections, this isn't enough, and the 10 connections will just all fail, timing out one after the other. This is an issue.
Now this behavior may not seem so smart. Personally, if I was trying to connect by hand, I'd try to first IP address, then if it fails the second one, then maybe the third one because I'm patient, but no way I'd go through all 10 addresses just to see them all fail. So I suggest improving this. One possibility would be to truncate the list of IP addresses to try, or to give up after it consistently fails so many times (which is effectively the same). An interesting idea would be, instead of equally dividing 2 seconds, to for example try the first address for 1 second, then if it fails the second one for 500 ms, then the third one for 250 ms and then whatever (if waiting didn't help for the first address, I'm not very likely to wait a long time for the following ones too). Another way would be to guarantee a minimum value above the RTT (like 500 ms) below which the connect timeout for one address won't drop when divided between many of them; this value could be either hardcoded or a new configuration option. What do you think? Regards, -- Pierre Ynard "Une âme dans un corps, c'est comme un dessin sur une feuille de papier." ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.html
