Even if it does hit a down server twice, it'll still just randomize and try
again hopefully hitting one that's not down. This shouldn't lose any mail
and shouldn't take much, if any, extra system resources.
So the actual string that 'j' scans looks something like this:
192.168.20.1\0192.168.20.2\0192.168.20.3
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 21, 2000 3:44 PM
To: [EMAIL PROTECTED]
Subject: Re: qmqpc load balancing
On Fri, Jul 21, 2000 at 04:35:57PM -0400, Paul Jarc wrote:
> [EMAIL PROTECTED] writes:
> > 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.
> ...
> > > This way, "i" will be a random number from 0 to (servers.len-1).
> >
> > 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.
>
> Also note that if you choose one at random every time, you just might
> choose the same one, which happens to be down, every time. It'd be
> better to rotate the list by a random number of entries, and then step
> through it normally.
I think he as trying to randomize the start point and cycle thru the
list as qmqpc does now. So even if he hits the same starting point,
it'll still find a good server. Leastwise that's what I was originally
trying to show with the posted code-fragment.
Regards.