]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: cache: Don't request more room than the max allowed
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 9 May 2023 09:31:24 +0000 (11:31 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 9 May 2023 09:53:28 +0000 (11:53 +0200)
Since a recent change on the SC API, a producer must specify the amount of
free space it needs to progress when it is blocked. But, it must take care
to never exceed the maximum size allowed in the buffer. Otherwise, the
stream is freezed because it cannot reach the condition to unblock the
producer.

In this context, there is a bug in the cache applet when it fails to dump a
message. It may request more space than allowed. It happens when the cached
object is too big.

It is a 2.8-specific bug. No backport needed.

src/cache.c

index cebd17e3de25bfa62eab11acbe17c33aac5add03..8118387c9f7df93c49c6eafffe349d3251a69ddc 100644 (file)
@@ -1513,7 +1513,7 @@ static void http_cache_io_handler(struct appctx *appctx)
                if (len) {
                        ret = htx_cache_dump_msg(appctx, res_htx, len, HTX_BLK_UNUSED);
                        if (ret < len) {
-                               sc_need_room(sc, len - ret);
+                               sc_need_room(sc, channel_htx_recv_max(res, res_htx) + 1);
                                goto out;
                        }
                }