]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stconn: Use a small buffer if possible for L7 retries
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 16 Mar 2026 10:25:35 +0000 (11:25 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 23 Mar 2026 13:02:43 +0000 (14:02 +0100)
Whe L7 retries are enabled and the request is small enough, a small buffer
is used instead of a regular one.

src/stconn.c

index 1aa136affe70368bfc06c5306d1aff8b08986923..84ceb0841ba9380f643e5f38c22566ee140e41f3 100644 (file)
@@ -1496,16 +1496,20 @@ int sc_conn_send(struct stconn *sc)
                        if (s->txn->req.msg_state != HTTP_MSG_DONE || b_is_large(&oc->buf))
                                s->txn->flags &= ~TX_L7_RETRY;
                        else {
-                               if (b_alloc(&s->txn->l7_buffer, DB_UNLIKELY) == NULL)
-                                       s->txn->flags &= ~TX_L7_RETRY;
-                               else {
-                                       memcpy(b_orig(&s->txn->l7_buffer),
-                                              b_orig(&oc->buf),
-                                              b_size(&oc->buf));
-                                       s->txn->l7_buffer.head = co_data(oc);
-                                       b_add(&s->txn->l7_buffer, co_data(oc));
+                               if (!htx_copy_to_small_buffer(&s->txn->l7_buffer, &oc->buf)) {
+                                       if (b_alloc(&s->txn->l7_buffer, DB_UNLIKELY) == NULL)
+                                               s->txn->flags &= ~TX_L7_RETRY;
+                                       else {
+                                               memcpy(b_orig(&s->txn->l7_buffer),
+                                                      b_orig(&oc->buf),
+                                                      b_size(&oc->buf));
+                                       }
                                }
 
+                               if (s->txn->flags & TX_L7_RETRY) {
+                                       s->txn->l7_buffer.head = co_data(oc);
+                                       b_set_data(&s->txn->l7_buffer, co_data(oc));
+                               }
                        }
                }