]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: hlua/htx: Reset channels analyzers when txn:done() is called
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 26 Jul 2019 14:40:24 +0000 (16:40 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 29 Jul 2019 09:17:52 +0000 (11:17 +0200)
For HTX streams, when txn:done() is called, the work is delegated to the
function http_reply_and_close(). But it is not enough. The channel's analyzers
must also be reset. Otherwise, some analyzers may still be called while
processing should be aborted.

For instance, if the function is called from an http-request rules on the
frontend, request analyzers on the backend side are still called. So we may try
to add an header to the request, while this one was already reset.

This patch must be backported to 2.0 and 1.9.

src/hlua.c

index 58803e2b3bbfd6d99a0052af0b33faef37ff89fc..63768aa63b91a82febe2d459c5916ef822fa846b 100644 (file)
@@ -5374,8 +5374,10 @@ __LJMP static int hlua_txn_done(lua_State *L)
        ic = &htxn->s->req;
        oc = &htxn->s->res;
 
-       if (IS_HTX_STRM(htxn->s))
+       if (IS_HTX_STRM(htxn->s)) {
+               htxn->s->txn->status = 0;
                http_reply_and_close(htxn->s, 0, NULL);
+       }
        else {
                channel_auto_read(ic);
                channel_abort(ic);
@@ -5387,9 +5389,14 @@ __LJMP static int hlua_txn_done(lua_State *L)
                channel_auto_close(oc);
                channel_shutr_now(oc);
 
-               ic->analysers = 0;
        }
 
+       ic->analysers &= AN_REQ_FLT_END;
+       oc->analysers &= AN_RES_FLT_END;
+
+       if (!(htxn->s->flags & SF_ERR_MASK))      // this is not really an error but it is
+               htxn->s->flags |= SF_ERR_LOCAL;   // to mark that it comes from the proxy
+
        hlua->flags |= HLUA_STOP;
        WILL_LJMP(hlua_done(L));
        return 0;