From: Christopher Faulet Date: Tue, 29 Sep 2026 06:54:25 +0000 (+0200) Subject: BUG/MINOR: chunk: Allow large chunks uses from large const buffers X-Git-Tag: v3.5-dev8~100 X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=dc8398145d25e66a58de35fda4ba9b741acb79e2;p=haproxy.git BUG/MINOR: chunk: Allow large chunks uses from large const buffers When a chunk was retrieved via get_best_trash_chunk() or alloc_best_trash_chunk(), it was not possible to get a large chunk when the original buffer was a constant 0-sized buffer, independently on size of data pointed by it. With this patch, we relaxe the test. It is now possible to get a large chunks from a 0-sized buffer if it points on large data. Indeed, in that case, it means that data are hosted in a large buffer, so it is safe to get a large chunk if possible. This patch should be backported to 3.4 after a period of observation. --- diff --git a/include/haproxy/chunk.h b/include/haproxy/chunk.h index bf6f3e7e2..10ba607f2 100644 --- a/include/haproxy/chunk.h +++ b/include/haproxy/chunk.h @@ -181,7 +181,7 @@ static forceinline struct buffer *alloc_trash_chunk_sz(size_t size) */ static forceinline struct buffer *alloc_best_trash_chunk(const struct buffer *buf, size_t size) { - if (pool_head_large_trash && buf->size == pool_head_large_trash->size) + if (pool_head_large_trash && (buf->size == pool_head_large_trash->size || buf->data > pool_head_trash->size)) return alloc_trash_chunk_sz(size); else if (size <= pool_head_trash->size) return alloc_trash_chunk(); diff --git a/src/chunk.c b/src/chunk.c index f82bd4af6..99ab7beeb 100644 --- a/src/chunk.c +++ b/src/chunk.c @@ -168,7 +168,7 @@ struct buffer *get_trash_chunk_sz(size_t size) */ struct buffer *get_best_trash_chunk(const struct buffer *buf, size_t size) { - if (large_trash_size && buf->size == large_trash_size) + if (large_trash_size && (buf->size == large_trash_size || buf->data > trash_size)) return get_trash_chunk_sz(size); else if (size <= trash_size) return get_trash_chunk();