]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stream: Try to use small buffer when TCP stream is queued
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 10 Mar 2026 15:27:03 +0000 (16:27 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 23 Mar 2026 13:02:42 +0000 (14:02 +0100)
It was performed when an HTX stream was queued. Small requests were moved in
small buffers. Here we do the same but for TCP streams.

src/stream.c

index 28989bd2f35ddeadf354270efb35887348fb533d..8886763bf18d2ef6471b4783baf6475409006639 100644 (file)
@@ -2512,11 +2512,22 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
                        if (scb->state == SC_ST_ASS && srv && srv->rdr_len && (s->flags & SF_REDIRECTABLE))
                                http_perform_server_redirect(s, scb);
 
-                       if (unlikely(scb->state == SC_ST_QUE && IS_HTX_STRM(s))) {
+                       if (unlikely(scb->state == SC_ST_QUE)) {
                                struct buffer sbuf = BUF_NULL;
 
-                               if (!htx_move_to_small_buffer(&sbuf, &req->buf))
-                                       break;
+                               if (IS_HTX_STRM(s)) {
+                                       if (!htx_move_to_small_buffer(&sbuf, &req->buf))
+                                               break;
+                               }
+                               else {
+                                       if (b_size(&req->buf) == global.tune.bufsize_small ||
+                                           b_data(&req->buf) > global.tune.bufsize_small)
+                                               break;
+                                       if (!b_alloc_small(&sbuf))
+                                               break;
+                                       b_xfer(&sbuf, &req->buf, b_data(&req->buf));
+                               }
+
                                b_free(&req->buf);
                                offer_buffers(s, 1);
                                req->buf = sbuf;