Re: wget breaks round-robin dns?

2006-07-23 Thread Hrvoje Niksic
Matthias Kuehn [EMAIL PROTECTED] writes:

 it seems wget sorts the v4/v6 ip´s before creating a table of the
 returned ip´s.

Wget does really do that.  It does prefer IPv4 addresses to IPv6
addresses, and it caches the addresses resolved (but only during a
single Wget run), but it doesn't sort the addresses of the same
address family, it leaves them in the order returned by the resolver.

 try e.g.
 wget http://db.de.clamav.net/

$ wget http://db.de.clamav.net/ -d
...
Resolving db.de.clamav.net... 212.162.12.159, 62.26.160.3, 62.75.188.79, ...
Caching db.de.clamav.net = 212.162.12.159 62.26.160.3 62.75.188.79 
194.77.146.139 85.25.252.58 85.214.44.186 89.149.194.18 193.239.17.68 
195.246.234.199 213.9.78.42 213.209.100.191 217.115.136.166 217.160.141.39
Connecting to db.de.clamav.net|212.162.12.159|:80... connected.
...
$ wget http://db.de.clamav.net/ -d
...
Resolving db.de.clamav.net... 212.162.12.159, 62.26.160.3, 62.75.188.79, ...
Caching db.de.clamav.net = 212.162.12.159 62.26.160.3 62.75.188.79 
194.77.146.139 217.160.141.39 85.25.252.58 85.214.44.186 89.149.194.18 
193.239.17.68 195.246.234.199 213.9.78.42 213.209.100.191 217.115.136.166
Connecting to db.de.clamav.net|212.162.12.159|:80... connected.
$ wget http://db.de.clamav.net/ -d -O/dev/null
...
Resolving db.de.clamav.net... 212.162.12.159, 62.26.160.3, 62.75.188.79, ...
Caching db.de.clamav.net = 212.162.12.159 62.26.160.3 62.75.188.79 
194.77.146.139 85.25.252.58 85.214.44.186 89.149.194.18 193.239.17.68 
195.246.234.199 213.9.78.42 213.209.100.191 217.115.136.166 217.160.141.39
Connecting to db.de.clamav.net|212.162.12.159|:80... connected.
...

As you can see, the order cached (and used) is not the same across
several Wget runs, but the first several addresses returned by the
resolver are.

 compiling with ipv6 disabled seems to work on v4, and no sorting is
 done. randomizing (as suggested on the mailing-list) is no good
 idea, because wget still has a different result from what the
 resolver returned.

If it works without IPv6, then it means that getaddrinfo on your
machine sorts the results, whereas gethostbyname doesn't.  The only
sorting Wget does is sorting by address family (which is a stable
sort that preserves the order of addresses within an address family),
and that one is disabled using --prefer-family=none.


Re: wget breaks round-robin dns?

2006-07-23 Thread Daniel Stenberg

On Sun, 23 Jul 2006, Hrvoje Niksic wrote:

If it works without IPv6, then it means that getaddrinfo on your machine 
sorts the results, whereas gethostbyname doesn't.


This effect has been seen (and reported) before on getaddrinfo vs 
gethostbyname and I've tried to get the glibc guys interested enough to answer 
why this is but have failed so far.


I can easily repeat this (bad) behaviour using a stand-alone test program 
using a very recent glibc, so this is in no way wget's fault.


If anyone would like to try the tests or dive further into this, my test 
program can be found here:


http://curl.haxx.se/mail/lib-2005-11/0008.html

--
 -=- Daniel Stenberg -=- http://daniel.haxx.se -=-
  ech`echo xiun|tr nu oc|sed 'sx\([s\x]\)\([\xoi]\)xo un\2\1 is xg'`ol