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.
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:
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;