BUG/MEDIUM: lua: direction test failed
Lua needs to known the direction of the http data processed (request or
response). It checks the flag SMP_OPT_DIR_REQ, buf this flag is 0. This patch
correctly checks the flags after applying the SMP_OPT_DIR mask.
diff --git a/src/hlua.c b/src/hlua.c
index 56dac47..2fc492c 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -5275,7 +5275,7 @@
switch (hlua_ctx_resume(&stream->hlua, 0)) {
/* finished. */
case HLUA_E_OK:
- if (!hlua_check_proto(stream, !(smp->opt & SMP_OPT_DIR_REQ)))
+ if (!hlua_check_proto(stream, (smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES))
return 0;
/* Convert the returned value in sample. */
hlua_lua2smp(stream->hlua.T, -1, smp);
@@ -5287,13 +5287,13 @@
/* yield. */
case HLUA_E_AGAIN:
- hlua_check_proto(stream, !(smp->opt & SMP_OPT_DIR_REQ));
+ hlua_check_proto(stream, (smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES);
SEND_ERR(smp->px, "Lua sample-fetch '%s': cannot use yielded functions.\n", fcn->name);
return 0;
/* finished with error. */
case HLUA_E_ERRMSG:
- hlua_check_proto(stream, !(smp->opt & SMP_OPT_DIR_REQ));
+ hlua_check_proto(stream, (smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES);
/* Display log. */
SEND_ERR(smp->px, "Lua sample-fetch '%s': %s.\n",
fcn->name, lua_tostring(stream->hlua.T, -1));
@@ -5301,7 +5301,7 @@
return 0;
case HLUA_E_ERR:
- hlua_check_proto(stream, !(smp->opt & SMP_OPT_DIR_REQ));
+ hlua_check_proto(stream, (smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES);
/* Display log. */
SEND_ERR(smp->px, "Lua sample-fetch '%s' returns an unknown error.\n", fcn->name);