]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: chunk: Allow large chunks uses from large const buffers
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 29 Sep 2026 06:54:25 +0000 (08:54 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 29 Sep 2026 12:30:21 +0000 (14:30 +0200)
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.

include/haproxy/chunk.h
src/chunk.c

index bf6f3e7e22e36b0ef02e16fafba3d711ef3fe902..10ba607f2307ff6ee14725160ca463358f6f56bb 100644 (file)
@@ -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();
index f82bd4af66cb1f833179d408e1c8707666e83cb0..99ab7beeb81c2f731ef3d0ec5f8368aa45b59646 100644 (file)
@@ -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();