]> git.kaiwu.me - haproxy.git/commitdiff
BUN/MINOR: hlua: reset hlua_body variable after per-thread files loading
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 1 Sep 2026 14:51:54 +0000 (16:51 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 1 Sep 2026 15:56:07 +0000 (17:56 +0200)
hlua_body variable was introduced to know if the files loading was passed or
not and emit warnings if some operations are performed during runtime. In
particular, it was used to detect calls to core.use_native_mailers_config()
during runtime.

However, the hlua_body variable was reset too early in the post-init
function, before the per-thread files loading. Because of this issue,
loading mailers.lua script using 'lua-load-per-thread' directive led to the
following error during haproxy startup:

  ... use_native_mailers_config: not available outside of body context

To fix the issue, this variable is now reset at the end of the function.

This patch must be backported as far as 3.3. It should fix the issue #3487.

src/hlua.c

index 1882db98ab1e5a7503298040b1b99c49362107ac..a4d6826351aa41049eb63b59f0a0cae1519dbeed 100644 (file)
@@ -13520,9 +13520,6 @@ int hlua_post_init()
        struct hlua_function *fcn;
        struct hlua_reg_filter *reg_flt;
 
-       hlua_body = 0;
-
-
 #if defined(USE_OPENSSL)
        /* Initialize SSL server. */
        if (socket_ssl->xprt->prepare_srv) {
@@ -13642,6 +13639,8 @@ int hlua_post_init()
        if (errors > 0)
                return 0;
 
+       hlua_body = 0;
+
        /* after this point, this global will no longer be used, so set to
         * -1 in order to have probably a segfault if someone use it
         */