mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-04 11:05:08 -05:00
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:
4
sched.c
4
sched.c
@@ -375,10 +375,10 @@ SCH_AddTimeoutInClass(double min_delay, double separation, double randomness,
|
|||||||
assert(class < SCH_NumberOfClasses);
|
assert(class < SCH_NumberOfClasses);
|
||||||
|
|
||||||
if (randomness > 0.0) {
|
if (randomness > 0.0) {
|
||||||
uint16_t rnd;
|
uint32_t rnd;
|
||||||
|
|
||||||
UTI_GetRandomBytes(&rnd, sizeof (rnd));
|
UTI_GetRandomBytes(&rnd, sizeof (rnd));
|
||||||
r = rnd / (double)0xffff * randomness + 1.0;
|
r = rnd * (randomness / (uint32_t)-1) + 1.0;
|
||||||
min_delay *= r;
|
min_delay *= r;
|
||||||
separation *= r;
|
separation *= r;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user