Draft #2: Re: [PATCH] SAMBA_3_0 : remove ldap_domain2hostlist()

Gerald (Jerry) Carter jerry at samba.org
Fri May 5 17:06:33 GMT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Love Hörnquist Åstrand wrote:

> I looked at the code with qsort, yes. 
> 
> If you have two entries, will both of the get selected with appropriate
> distribution ? With your correct code, I don't think so.
> 
> priority=1,weight=2
> priority=1,weight=1

The list is ordered such that the caller will use entries in the front
of the list first.  So from your example, the order would be:
{p=1,w=2} {p=1,w=1}.  This is the best we can do with how the
current SAMBA_3_0 code makes use of IP lists to select domain
controllers.

Here's my current comparison function.

static int dnssrvcmp( struct dns_rr_srv *a, struct dns_rr_srv *b )
{
    BOOL init = False;

    if ( !init ) {
        srand( (uint32)time(NULL);
    }

    if ( a->priority == b->priority ) {

        /* randomize entries with an equal weight and priority */
        if ( a->weight == b->weight )
            return rand() % 2 ? -1 : 1;

        /* higher weights should be sorted lower so they
           are selected first */
        if ( a->weight > b->weight )
               return -1;
        else
               return 1;
    }

    if ( a->priority < b->priority )
        return -1;

    return 1;
}


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFEW4YYIR7qMdg1EfYRAjA9AKDJMy0jo+huymXXz9yNABtXevw5zACg76PU
aEhxlNN3CCNZly6J11MmB4I=
=hXM5
-----END PGP SIGNATURE-----


More information about the samba-technical mailing list