]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: allocate stream txbuf via qc_stream_desc API
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 13 Aug 2024 09:08:08 +0000 (11:08 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 20 Aug 2024 15:17:17 +0000 (17:17 +0200)
This commit simply adjusts QUIC stream buffer allocation. This operation
is conducted by QUIC MUX using qc_stream_desc layer. Previously,
qc_stream_buf_alloc() would return a qc_stream_buf instance and QUIC MUX
would finalized the buffer area allocation. Change this to perform the
buffer allocation directly into qc_stream_buf_alloc().

This patch clarifies the interaction between QUIC MUX and
qc_stream_desc. It is cleaner to allocate the buffer via qc_stream_desc
as it is already responsible to free the buffer.

It also ensures that connection buffer accounting is only done after the
whole qc_stream_buf and its buffer are allocated. Previously, the
increment operation was performed between the two steps. This was not an
issue, as this kind of error triggers the whole connection closure.
However, if in the future this is handled as a stream closure instead,
this commit ensures that the buffer remains valid in all cases.

src/mux_quic.c
src/quic_stream.c

index 8755f742ac86d2e495b0d38582d00dfa5744e7ce..30882ab2ebf63c5d44556f64f45a21113ecdf62f 100644 (file)
@@ -1037,12 +1037,6 @@ struct buffer *qcc_get_stream_txbuf(struct qcs *qcs, int *err)
                        qcc->flags |= QC_CF_CONN_FULL;
                        goto out;
                }
-
-               if (!b_alloc(out, DB_MUX_TX)) {
-                       TRACE_ERROR("buffer alloc failure", QMUX_EV_QCS_SEND, qcc->conn, qcs);
-                       *err = 1;
-                       goto out;
-               }
        }
 
  out:
index 1d7a3c4de90edf4d3ea0a671d8049c319ee090af..a21391346bde74bf7dd97759e72ddf6aacb7ae62 100644 (file)
@@ -297,9 +297,13 @@ struct buffer *qc_stream_buf_alloc(struct qc_stream_desc *stream,
        if (!stream->buf)
                return NULL;
 
-       ++qc->stream_buf_count;
+       if (!b_alloc(&stream->buf->buf, DB_MUX_TX)) {
+               pool_free(pool_head_quic_stream_buf, stream->buf);
+               stream->buf = NULL;
+               return NULL;
+       }
 
-       stream->buf->buf = BUF_NULL;
+       ++qc->stream_buf_count;
        LIST_APPEND(&stream->buf_list, &stream->buf->list);
 
        return &stream->buf->buf;