From: Willy Tarreau Date: Wed, 12 Oct 2022 19:48:17 +0000 (+0200) Subject: MINOR: checks: use the lighter PRNG for spread checks X-Git-Tag: v2.7-dev8~28 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a840b4a39b8d6c6c09b8681f61d778f4e00bedca;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/check.c b/src/check.c index 5a6ee08a54..34791dd249 100644 --- a/src/check.c +++ b/src/check.c @@ -1226,7 +1226,7 @@ struct task *process_chk_conn(struct task *t, void *context, unsigned int state) rv = 0; if (global.spread_checks > 0) { 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)); } diff --git a/src/extcheck.c b/src/extcheck.c index 2093b40514..0fd35a1178 100644 --- a/src/extcheck.c +++ b/src/extcheck.c @@ -596,7 +596,7 @@ struct task *process_chk_proc(struct task *t, void *context, unsigned int state) rv = 0; if (global.spread_checks > 0) { 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)); }