]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: bwlim: Reset analyse expiration date when then channel analyse ends
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 1 Aug 2023 06:16:42 +0000 (08:16 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 1 Aug 2023 09:33:45 +0000 (11:33 +0200)
The bandwidth limitation filter sets the analyse expiration date on the
channel to restart the data forwarding and thus limit the bandwidth.
However, this expiration date is not reset on abort. So it is possible to
reuse the same expiration date to set the stream one. If it expired before
the end of the stream, this will lead to a spinning loop on process_stream()
because the task expiration date is always set in past.

To fix the issue, when the analyse ends on a channel, the bandwidth
limitation filter reset the corrsponding analyse expiration date.

This patch should fix the issue #2230. It must be backported as far as 2.7.

src/flt_bwlim.c

index c9cdf2f90413927f6fc8f83219f99b738290f849..27db231fd1c519ad6b987cdaf776da21b57eb941 100644 (file)
@@ -288,6 +288,18 @@ static void bwlim_detach(struct stream *s, struct filter *filter)
        filter->ctx = NULL;
 }
 
+/**************************************************************************
+ * Hooks to handle channels activity
+ *************************************************************************/
+
+/* Called when analyze ends for a given channel */
+static int bwlim_chn_end_analyze(struct stream *s, struct filter *filter, struct channel *chn)
+{
+       chn->analyse_exp = TICK_ETERNITY;
+        return 1;
+}
+
+
 /**************************************************************************
  * Hooks to filter HTTP messages
  *************************************************************************/
@@ -325,6 +337,8 @@ struct flt_ops bwlim_ops = {
        .attach             = bwlim_attach,
        .detach             = bwlim_detach,
 
+               /* Handle channels activity */
+        .channel_end_analyze = bwlim_chn_end_analyze,
 
        /* Filter HTTP requests and responses */
        .http_headers        = bwlim_http_headers,