]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: stream: Decrement server current session counter on L7 retry
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 5 May 2021 16:23:59 +0000 (18:23 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 6 May 2021 07:21:12 +0000 (09:21 +0200)
When a L7 retry is performed, we must not forget to decrement the current
session counter of the assigned server. Of course, it must only be done if
the current session is already counted on the server, thus if SF_CURR_SESS
flag is set on the stream.

This patch is related to the issue #1003. It must be backported as far as
2.0.

src/http_ana.c

index f662a31b9de76854e217837f65bceb90372fa0ab..7c5e3ff66de3468dc32eb93aeee3e5633038497c 100644 (file)
@@ -1295,8 +1295,13 @@ static __inline int do_l7_retry(struct stream *s, struct stream_interface *si)
        if (b_is_null(&req->buf) && !channel_alloc_buffer(req, &s->buffer_wait))
                goto no_retry;
 
-       if (objt_server(s->target))
+       if (objt_server(s->target)) {
+               if (s->flags & SF_CURR_SESS) {
+                       s->flags &= ~SF_CURR_SESS;
+                       _HA_ATOMIC_DEC(&__objt_server(s->target)->cur_sess);
+               }
                _HA_ATOMIC_INC(&__objt_server(s->target)->counters.retries);
+       }
        _HA_ATOMIC_INC(&s->be->be_counters.retries);
 
        /* Remove any write error from the request, and read error from the response */