MINOR: hlua: Test the hlua struct first when the lua socket is connecting

It makes sense to first verify the hlua context is valid. It is probably
better than doing it after updated the appctx.
This commit is contained in:
Christopher Faulet 2023-09-27 17:42:38 +02:00
parent 6f4041c75d
commit 66fc9238f0

View File

@ -3148,6 +3148,11 @@ __LJMP static int hlua_socket_connect(struct lua_State *L)
struct stconn *sc; struct stconn *sc;
struct stream *s; 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) if (lua_gettop(L) < 2)
WILL_LJMP(luaL_error(L, "connect: need at least 2 arguments")); 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")); 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 /* inform the stream that we want to be notified whenever the
* connection completes. * connection completes.
*/ */