]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: http: Call stream_inc_be_http_req_ctr() only one time per request
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 29 Apr 2019 11:12:02 +0000 (13:12 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 29 Apr 2019 14:01:47 +0000 (16:01 +0200)
The function stream_inc_be_http_req_ctr() is called at the beginning of the
analysers AN_REQ_HTTP_PROCESS_FE/BE. It as an effect only on the backend. But we
must be careful to call it only once. If the processing of HTTP rules is
interrupted in the middle, when the analyser is resumed, we must not call it
again. Otherwise, the tracked counters of the backend are incremented several
times.

This bug was reported in github. See issue #74.

This fix should be backported as far as 1.6.

src/proto_http.c
src/proto_htx.c

index 5776a4784ab1b0dd41cc90723a3d9cd17130ea3e..2ab33154272a09414820c8eb02b6843284f86b16 100644 (file)
@@ -2533,8 +2533,10 @@ int http_process_req_common(struct stream *s, struct channel *req, int an_bit, s
                ci_data(req),
                req->analysers);
 
-       /* just in case we have some per-backend tracking */
-       stream_inc_be_http_req_ctr(s);
+       /* just in case we have some per-backend tracking. Only called the first
+        * execution of the analyser. */
+       if (!s->current_rule || s->current_rule_list != &px->http_req_rules)
+               stream_inc_be_http_req_ctr(s);
 
        /* evaluate http-request rules */
        if (!LIST_ISEMPTY(&px->http_req_rules)) {
index d2c03e180beabd0afb7fded9a2b3ed174374d995..ee9a2716f208389160ed8b2dd9ad96596588016e 100644 (file)
@@ -501,8 +501,10 @@ int htx_process_req_common(struct stream *s, struct channel *req, int an_bit, st
 
        htx = htxbuf(&req->buf);
 
-       /* just in case we have some per-backend tracking */
-       stream_inc_be_http_req_ctr(s);
+       /* just in case we have some per-backend tracking. Only called the first
+        * execution of the analyser. */
+       if (!s->current_rule || s->current_rule_list != &px->http_req_rules)
+               stream_inc_be_http_req_ctr(s);
 
        /* evaluate http-request rules */
        if (!LIST_ISEMPTY(&px->http_req_rules)) {