]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: hlua: Test the hlua struct first when the lua socket is connecting
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 27 Sep 2023 15:42:38 +0000 (17:42 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 4 Oct 2023 13:34:10 +0000 (15:34 +0200)
It makes sense to first verify the hlua context is valid. It is probably
better than doing it after updated the appctx.

src/hlua.c

index 39b64dc38c625e2891e1e15a0029bee844a30c85..fbed29946e876f069674c20a8b27ab7ab4cfd2ce 100644 (file)
@@ -3148,6 +3148,11 @@ __LJMP static int hlua_socket_connect(struct lua_State *L)
        struct stconn *sc;
        struct stream *s;
 
+       /* Get hlua struct, or NULL if we execute from main lua state */
+       hlua = hlua_gethlua(L);
+       if (!hlua)
+               return 0;
+
        if (lua_gettop(L) < 2)
                WILL_LJMP(luaL_error(L, "connect: need at least 2 arguments"));
 
@@ -3222,11 +3227,6 @@ __LJMP static int hlua_socket_connect(struct lua_State *L)
                WILL_LJMP(luaL_error(L, "connect: internal error"));
        }
 
-       /* Get hlua struct, or NULL if we execute from main lua state */
-       hlua = hlua_gethlua(L);
-       if (!hlua)
-               return 0;
-
        /* inform the stream that we want to be notified whenever the
         * connection completes.
         */