sched: add more random bits to timeout scheduling

Extend the random value which is included in the calculation of the
delay from 16 to 32 bits. This makes scheduling of NTP transmissions
random to one microsecond for polling intervals up to 17.
This commit is contained in:
Miroslav Lichvar 2016-11-14 08:43:54 +01:00
parent 74f581e7ab
commit 4b0ef09221

View file

@ -375,10 +375,10 @@ SCH_AddTimeoutInClass(double min_delay, double separation, double randomness,
assert(class < SCH_NumberOfClasses);
if (randomness > 0.0) {
uint16_t rnd;
uint32_t rnd;
UTI_GetRandomBytes(&rnd, sizeof (rnd));
r = rnd / (double)0xffff * randomness + 1.0;
r = rnd * (randomness / (uint32_t)-1) + 1.0;
min_delay *= r;
separation *= r;
}