Autor: Alan Barrett Data: Para: exim-users Asunto: Re: split the load?
[sorry about my previous content-free message. I pressed the send
button instead of teh cancel button by mistake.]
Neal Becker <neal@???> said: > I would just generate a random integer (using random(), for example),
> then if there are n slots just do:
>
> int i = random() % n;
Yes, I would do it like that too (That is, I would be inclined to ignore
the small biases that would result from random()'s range not being a
multiple of n, and to ignore the fact that random()'s underlying algorithm
is likely to be poor in most implementations).
However, I would start by seeding the random number generator with
something from a moderately good randomness source. See the way ssh gets
randomness for ideas (call functions like gettimeofday() and
gethostname(), run commands like "ps" and "who", read some bytes from
/dev/urandom if your system has it, and hash all that with something like
MD5 or SHA).