]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: checks: use the lighter PRNG for spread checks
authorWilly Tarreau <w@1wt.eu>
Wed, 12 Oct 2022 19:48:17 +0000 (21:48 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 12 Oct 2022 19:49:30 +0000 (21:49 +0200)
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.

src/check.c
src/extcheck.c

index 5a6ee08a54992c0cf09999674c9dc215446f79e1..34791dd249f07b3ab2ebd8945b06e65907556171 100644 (file)
@@ -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));
        }
index 2093b405143448d038112aa6729e9fc5ce5deb7e..0fd35a117857f51f84bf1550a1dda7a6fb47b14f 100644 (file)
@@ -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));
        }