On Thu, 21 Nov 1996, Warner Losh wrote:
> It doesn't matter if you get the results back randomly or not. If you
> pick randomly from them, you are guaranteed to still have a random
> distribution. If you pick randomly from a non-random set, you have a
> random distribution. Therefore, it is irrelevant the order that DNS
> gives you the MX records in. Picking one of these at random is the
> right thing to do. If someone wants you to give precidence to one of
> these hosts, then by definition, that someone must change the MX
> precidence to be a lower value.
It's not quite "pick one at random". You have to put them into a random
order so that you can try them in turn until one works.
I think I'm convinced that "randomizing" is perhaps a better thing to
do. A *simple* scheme would not be expensive, but I know that I don't
know enough about random numbers to want to get involved in trying to
ensure true randomness. We are talking here about "randomizing" a small
number of objects, often just two, probably never more than 10.
At the relevant time, Exim is scanning the list of RRs returned by the
nameserver, and inserting them into a list in order of their MX values.
The current rule is "insert before the entry with a higher MX value".
It would have to be changed by the addition of an extra rule such as
"If there are a group of entries with the same MX value, choose at
random where to insert." If there are n such entries, then there are n+1
possible places to insert. What is the best *cheap* way of getting a
random number between 0 and n? Is something like "take the last m bits
of the time of day modulo (n+1)" good enough for this purpose?
> What possible advantage would you have to using the first one of the
> list all the time? I don't get it.
Ease of implementation. :-)
--
Philip Hazel University Computing Service,
ph10@??? New Museums Site, Cambridge CB2 3QG,
P.Hazel@??? England. Phone: +44 1223 334714