]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: initcalls: Add a new initcall stage, STG_INIT_2
authorOlivier Houchard <ohouchard@haproxy.com>
Thu, 16 Oct 2025 13:45:52 +0000 (15:45 +0200)
committerOlivier Houchard <cognet@ci0.org>
Mon, 20 Oct 2025 13:04:41 +0000 (15:04 +0200)
Add a new initcall stage, STG_INIT_2, for stuff to be called after
step_init_2() is called, so after we know for sure that global.nbthread
will be set.
Modify stick-tables stkt_late_init() to run at STG_INIT_2 instead of
STG_INIT, in anticipation for it to be enhanced and have a need for
global.nbthread.

include/haproxy/initcall.h
src/haproxy.c
src/stick_table.c

index dffec04d17a74437ac61c7b6976857944b84c5e2..1f44e5e221b8e684d9579ceb2b9adf77f2a4b8f0 100644 (file)
@@ -67,6 +67,7 @@ enum init_stage {
        STG_ALLOC,            // allocate required structures
        STG_POOL,             // create pools
        STG_INIT,             // subsystems normal initialization
+       STG_INIT_2,           // runs after step_init_2, to have global.nbthread
        STG_SIZE              // size of the stages array, must be last
 };
 
@@ -202,6 +203,7 @@ DECLARE_INIT_SECTION(STG_REGISTER);
 DECLARE_INIT_SECTION(STG_ALLOC);
 DECLARE_INIT_SECTION(STG_POOL);
 DECLARE_INIT_SECTION(STG_INIT);
+DECLARE_INIT_SECTION(STG_INIT_2);
 
 // for use in the main haproxy.c file
 #define DECLARE_INIT_STAGES asm("")
index ab17fee6bfc64bf95286812fc1ad266801f02961..d6d7b131923956e7f764c6388757b760ffafc21e 100644 (file)
@@ -3378,6 +3378,7 @@ int main(int argc, char **argv)
         */
        step_init_2(argc, argv);
 
+       RUN_INITCALLS(STG_INIT_2);
        /* Late init step: register signals for worker and standalon modes, apply
         * nofile and memory limits, apply capabilities from binary, if any.
         */
index 5532fc679eece213f489891373e83e55c9c3ac73..08e08a03c8094972c32cd672c847b3f778292654 100644 (file)
@@ -5901,10 +5901,10 @@ static void stkt_late_init(void)
        f = find_sample_fetch("src", strlen("src"));
        if (f)
                smp_fetch_src = f->process;
-       hap_register_post_check(stkt_create_stk_ctr_pool);
+       stkt_create_stk_ctr_pool();
 }
 
-INITCALL0(STG_INIT, stkt_late_init);
+INITCALL0(STG_INIT_2, stkt_late_init);
 
 /* register cli keywords */
 static struct cli_kw_list cli_kws = {{ },{