[rbldnsd] The round-robin problem

Michael Tokarev rbldnsd@corpit.ru
Mon, 17 Nov 2003 08:10:15 +0300


Michael Tokarev wrote:
> furio ercolessi wrote:
> 
>> I noticed that rbldnsd (0.99) does not seem to do round robin rotation
>> of A records.  This can be a problem with zones that have the A
>> records of the nameservers within the zone itself, as it leads to
>> unbalancing.
> 
> Hmm.. not only it leads to unbalancing.  By using nameservers in the
[]
> Also, you're missing the point here.  The list of nameservers
...

Ghrm.  It's me who's missing the point.  You're not talking about
glue records as I thought before.  You're talking about any kinds
of repeated records in `generic' dataset.  And indeed, they aren't
being "rotated" in any way, and that's no good.  I see what you
mean finally (well.. i hope ;).

And while we're at it, a simple (programmer's) question: I've an
array with N elements.  N may be large (as it is not practical to
allocate something on the stack of this size).  And i want to
enumerate every element of the array, like for(i=0; i<N; ++i),
but in pseudo-random order.  What's the simplest way to do so?

At least, I may allocate a bitmap (one bit for each element),
set it to all-zeros initially, and until i'm done, get next
random index i in range 0..(N-1), check whenever i'th bit in
bitmap is set, continue if set, and "emit" i'th element of the
array (setting i'th bit in bitmap).  This looks clumsy at best.

Or, allocate another array of N elements, copy original array
into it, and again while any elements left, get random index
in range 0..N-1, emit ith element, let a[i] = a[N-1] (if i != N-1)
and decrease N.  Looks much better, but requires a copy of the
original array, or an array of indexes of the same size N...

Ok.  I think this record rotation may easily be done.  Hopefully
this week.

/mjt