Re: wget 1.10.x: New option --random to randomize the dns result
Hrvoje Niksic <[email protected]> Tue, 18 Apr 2006 14:45:33 +0200
| Newsgroups | gmane.comp.web.wget.patches |
|---|---|
| Message-ID | <[email protected]> |
Jerry Lundstr=F6m <[email protected]> writes: > Here is a patch that adds '--random' (rename at will). What it does is > to run address_list_randomize() after getting the dns result. > Reason I made this was because of IPv6 and RFC 3484 the dns result for > multi record hosts are sorted leaving round robins mirrors useless. What value does this option bring to the end user? Wget is hardly the most popular user agent, so even if it were the default, it wouldn't lessen the load on the web server. If you just need to test a site that uses round-robin DNS, you can always specify the needed IP address directly (and optionally correct the `Host' header using --header). > + int random; That should be bool. > + if (opt.random && al->count > 1) { > + int *tbl =3D xnew0_array(int, al->count); > + ip_address *ip =3D xnew0_array(ip_address, al->count); I don't understand the allocations. It should certainly be possible to shuffle an array in place! For example, see http://www.stanford.edu/~blp/writings/clc/shuffle.html Anyway, it's a better idea to add a generic shuffle() code to, say, utils.c, and just call it from host.c. > + /* fast init */ > + srandom(al->count*time(0)); Seeding the RNG should be done only once, not every time. Also note that [s]random is less portable than [s]rand. > - return al; > + return address_list_randomize(al); > } [...] > + al =3D address_list_randomize(al); You don't seem to be checking the value of opt.random at all.