BUG/MEDIUM: lua: In some case, the return of sample-fetche is ignored
When:
- A Lua action return data and close the channel. The request status
is set to HTTP_MSG_CLOSED for the request and HTTP_MSG_DONE for the
response.
- HAProxy sets the state HTTP_MSG_ERROR. I don't known why, because
there are many line which sets this state.
- A Lua sample-fetch is executed, typically for building the log
line.
- When the Lua sample fetch exits, a control of the data is
executed. If HAProxy is currently parsing the request, the request
is aborted in order to prevent a segfault or sending corrupted
data.
This ast control is executed comparing the state HTTP_MSG_BODY. When
this state is reached, the request is parsed and no error are
possible. When the state is < than HTTP_MSG_BODY, the parser is
running.
Unfortunately, the code HTTP_MSG_ERROR is just < HTTP_MSG_BODY. When
we are in error, we want to terminate the execution of Lua without
error.
This patch changes the comparaison level.
This patch must be backported in 1.6
diff --git a/src/hlua.c b/src/hlua.c
index 02e9b94..5594484 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -2413,13 +2413,13 @@
if (stream->be->mode == PR_MODE_HTTP) {
if (dir == SMP_OPT_DIR_REQ &&
!(stream->req.analysers & AN_REQ_WAIT_HTTP) &&
- stream->txn->req.msg_state < HTTP_MSG_BODY) {
+ stream->txn->req.msg_state < HTTP_MSG_ERROR) {
stream_int_retnclose(&stream->si[0], &msg);
return 0;
}
else if (dir == SMP_OPT_DIR_RES &&
!(stream->res.analysers & AN_RES_WAIT_HTTP) &&
- stream->txn->rsp.msg_state < HTTP_MSG_BODY) {
+ stream->txn->rsp.msg_state < HTTP_MSG_ERROR) {
stream_int_retnclose(&stream->si[0], &msg);
return 0;
}