Almost. Note that 'i' has to point to the start of the \0 terminated
string that 'j' is currently scanning. servers.s is a series of \0
terminated strings. You need to do some work to make sure that i, is
pointing that the start of the string that j randomizes into.


Regards.

On Fri, Jul 21, 2000 at 03:10:58PM -0500, Austad, Jay wrote:
> Instead of having qmqpc picking the first available server, I would like it
> to load balance between all servers I have listed as QMQP servers.  In
> qmail-qmqpc.c on line 153, it says:
>   i = 0;
>   for (j = 0;j < servers.len;++j)
>     if (!servers.s[j]) {
>       doit(servers.s + i);
>       i = j + 1;
>     }
> 
> 
> Would it work if I change it to:
>   i = 0;
>   for (j = 0;j < servers.len;++j)
>     i = (servers.len*1.0)*rand()/(RAND_MAX+1.0);
>     if (!servers.s[j]) {
>       doit(servers.s + i);
>     }
> 
> This way, "i" will be a random number from 0 to (servers.len-1).  
> 
> 
> ----------
> Jay Austad
> Network Administrator
> CBS Marketwatch
> 612.817.1271
> [EMAIL PROTECTED]
> http://cbs.marketwatch.com
> http://www.bigcharts.com
> 
> 

Reply via email to