-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
This functionality is needed for service discovery.
RFC 2782 defines a way to sort replies to a SRV query. In short, the algorithm sorts all replies by priority and then does a weight-based selection for every priority level.
For details, please see the sections "Usage rules" for overview of the algorithm and section "The 'Weight' field" for description on the weight selection.
On 04/22/2010 06:45 AM, Jakub Hrozek wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
This functionality is needed for service discovery.
RFC 2782 defines a way to sort replies to a SRV query. In short, the algorithm sorts all replies by priority and then does a weight-based selection for every priority level.
For details, please see the sections "Usage rules" for overview of the algorithm and section "The 'Weight' field" for description on the weight selection.
Nack.
While this is clearly not a case where random values need to be highly random, on some implementations rand() is not uniformly distributed in the low-order bits. In order to be more portable, we should use
selected = (int)((total + 1) * (rand()/(RAND_MAX + 1.0)))
This will give a random integer from 0 to total (inclusive) using the high-order bits returned by rand().
Otherwise this looks good.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 04/22/2010 02:43 PM, Stephen Gallagher wrote:
Nack.
While this is clearly not a case where random values need to be highly random, on some implementations rand() is not uniformly distributed in the low-order bits. In order to be more portable, we should use
selected = (int)((total + 1) * (rand()/(RAND_MAX + 1.0)))
Thanks for the suggestion, a new patch is attached, also fixes a whitespace issue.
On 04/22/2010 12:25 PM, Jakub Hrozek wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 04/22/2010 02:43 PM, Stephen Gallagher wrote:
Nack.
While this is clearly not a case where random values need to be highly random, on some implementations rand() is not uniformly distributed in the low-order bits. In order to be more portable, we should use
selected = (int)((total + 1) * (rand()/(RAND_MAX + 1.0)))
Thanks for the suggestion, a new patch is attached, also fixes a whitespace issue.
I thought I'd already acked this...
Ack.
On 04/27/2010 09:40 AM, Stephen Gallagher wrote:
On 04/22/2010 12:25 PM, Jakub Hrozek wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 04/22/2010 02:43 PM, Stephen Gallagher wrote:
Nack.
While this is clearly not a case where random values need to be highly random, on some implementations rand() is not uniformly distributed in the low-order bits. In order to be more portable, we should use
selected = (int)((total + 1) * (rand()/(RAND_MAX + 1.0)))
Thanks for the suggestion, a new patch is attached, also fixes a whitespace issue.
I thought I'd already acked this...
Ack.
Pushed to master and sssd-1-2.
sssd-devel@lists.fedorahosted.org