From 8dc7316a6fa8cc6f3a60456376c8a13a6902a5be Mon Sep 17 00:00:00 2001 From: "Thierry FOURNIER / OZON.IO" Date: Fri, 18 Nov 2016 19:06:21 +0100 Subject: [PATCH] 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 --- src/hlua.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hlua.c b/src/hlua.c index 02e9b94c9..559448404 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -2413,13 +2413,13 @@ static int hlua_check_proto(struct stream *stream, int dir) 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; }