MINOR: checks: use the lighter PRNG for spread checks

There's no point using ha_random32() which is heavy and uses shared
variables to calculate a random timer when we have statistical_prng()
which does the same and was made exactly for this.
This commit is contained in:
Willy Tarreau 2022-10-12 21:48:17 +02:00
parent 99521abd59
commit a840b4a39b
2 changed files with 2 additions and 2 deletions

View File

@ -1226,7 +1226,7 @@ struct task *process_chk_conn(struct task *t, void *context, unsigned int state)
rv = 0; rv = 0;
if (global.spread_checks > 0) { if (global.spread_checks > 0) {
rv = srv_getinter(check) * global.spread_checks / 100; rv = srv_getinter(check) * global.spread_checks / 100;
rv -= (int) (2 * rv * (ha_random32() / 4294967295.0)); rv -= (int) (2 * rv * (statistical_prng() / 4294967295.0));
} }
t->expire = tick_add(now_ms, MS_TO_TICKS(srv_getinter(check) + rv)); t->expire = tick_add(now_ms, MS_TO_TICKS(srv_getinter(check) + rv));
} }

View File

@ -596,7 +596,7 @@ struct task *process_chk_proc(struct task *t, void *context, unsigned int state)
rv = 0; rv = 0;
if (global.spread_checks > 0) { if (global.spread_checks > 0) {
rv = srv_getinter(check) * global.spread_checks / 100; rv = srv_getinter(check) * global.spread_checks / 100;
rv -= (int) (2 * rv * (ha_random32() / 4294967295.0)); rv -= (int) (2 * rv * (statistical_prng() / 4294967295.0));
} }
t->expire = tick_add(now_ms, MS_TO_TICKS(srv_getinter(check) + rv)); t->expire = tick_add(now_ms, MS_TO_TICKS(srv_getinter(check) + rv));
} }