curl-library
Re: multihomed connections
From: Gisle Vanem <gvanem_at_broadpark.no>
Date: Tue, 8 Jun 2004 20:18:40 +0200
Date: Tue, 8 Jun 2004 20:18:40 +0200
"Daniel Stenberg" <daniel-curl_at_haxx.se> said:
> > How is curl/libcurl supposed to connect to a host with multiple IPv4
> > addresses? I image it would try each address in succession.
>
> Yes, it should definitely. Anything else is a bug!
The fix to 'curl url1 url2' where url1 fails, is easy:
--- CVS-latest/src/main.c Tue May 25 16:44:25 2004
+++ src/main.c Tue Jun 08 19:37:18 2004
@@ -2904,7 +2904,7 @@
}
/* loop through the list of given URLs */
- while(urlnode && !res) {
+ while(urlnode) {
char *dourl;
/* get the full URL (it might be NULL) */
---- The other "bug" in libcurl is not a bug at all, but rather inconsitent behaviour depending on which resolver is used. Without C-ares (i.e. USE_THREADING_GETADDRINFO): >set CURL_TRACE=1 >curl -v4 http://ubr4-ca5-0-sec.landg1.lb.home.nl * Couldn't find host ubr4-ca5-0-sec.landg1.lb.home.nl in the .netrc file, using defaults 416: not yet 139: dump_addrinfo: fam 2, CNAME <none>, 10.221.110.1 fam 2, CNAME <none>, 82.72.140.1 fam 2, CNAME <none>, 10.243.112.1 fam 2, CNAME <none>, 82.73.204.1 fam 2, CNAME <none>, 217.121.93.1 fam 2, CNAME <none>, 217.122.53.1 fam 2, CNAME <none>, 217.123.132.1 353: getaddrinfo_thread() status 0, thread retval 0, 361: elapsed 15 ms * About to connect() to ubr4-ca5-0-sec.landg1.lb.home.nl port 80 * Connect failed; Connection refused * Closing connection #0 curl: (7) Connect failed; Connection refused Okay, the "refused" came from the last IP. Using tcpdump, I see curl tries the addresses in the above order. But with a C-ares version, the result is "timed out". Since the last IP it tried was 10.221.110.1. It would be nice if libcurl could tell us all the IP it tried and the result of each failed attempt. I.e. C-ares returns a completely different IP-order compared to what getaddrinfo() says. It looks like the DNS for this host is misconfigured too. Isn't addresses supposed to be listed in *prefered* order? BTW. try "adig www.cnn.com" and watch the IP-order changes constantly. Whereas the dig or host programs gives a more stable list of IPs. --gvReceived on 2004-06-08