]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: lua: In some case, the return of sample-fetche is ignored
authorThierry FOURNIER / OZON.IO <thierry.fournier@ozon.io>
Fri, 18 Nov 2016 18:06:21 +0000 (19:06 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 18 Nov 2016 23:29:19 +0000 (00:29 +0100)
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

index 02e9b94c9ea91a048a24d67a2cee284dd54524ed..5594484042123a584302dc40bcea4ab7367a757b 100644 (file)
@@ -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;
                }