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.
(cherry picked from commit 66fc9238f0c9860c2edd083ca87d0267faf44c5e)
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>
diff --git a/src/hlua.c b/src/hlua.c
index 6fca14b..f7d6c76 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -3121,6 +3121,11 @@
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"));
@@ -3195,11 +3200,6 @@
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.
*/