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.
This commit is contained in:
Thierry FOURNIER 2015-10-13 14:25:11 +02:00 committed by Willy Tarreau
parent 5a54921902
commit 26a7aacaff
1 changed files with 4 additions and 4 deletions

View File

@ -5275,7 +5275,7 @@ static int hlua_sample_fetch_wrapper(const struct arg *arg_p, struct sample *smp
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 @@ static int hlua_sample_fetch_wrapper(const struct arg *arg_p, struct sample *smp
/* 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 @@ static int hlua_sample_fetch_wrapper(const struct arg *arg_p, struct sample *smp
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);