return -1;
}
-/* Returns buffer for data sending.
- * May be NULL if the allocation failed.
- */
-static struct buffer *mux_get_buf(struct qcs *qcs)
-{
- if (!b_size(&qcs->tx.buf))
- b_alloc(&qcs->tx.buf);
-
- return &qcs->tx.buf;
-}
-
/* Function used to emit stream data from <qcs> control uni-stream */
static int h3_control_send(struct qcs *qcs, void *ctx)
{
b_quic_enc_int(&pos, h3_settings_max_field_section_size, 0);
}
- res = mux_get_buf(qcs);
+ res = qcc_get_stream_txbuf(qcs);
if (b_room(res) < b_data(&pos)) {
// TODO the mux should be put in blocked state, with
// the stream in state waiting for settings to be sent
list[hdr].n = ist("");
- res = mux_get_buf(qcs);
+ if (!(res = qcc_get_stream_txbuf(qcs)))
+ goto err;
/* At least 5 bytes to store frame type + length as a varint max size */
if (b_room(res) < 5)
}
list[hdr].n = ist("");
- res = mux_get_buf(qcs);
+ if (!(res = qcc_get_stream_txbuf(qcs)))
+ goto err;
/* At least 9 bytes to store frame type + length as a varint max size */
if (b_room(res) < 9) {
if (type != HTX_BLK_DATA)
goto end;
- res = mux_get_buf(qcs);
+ if (!(res = qcc_get_stream_txbuf(qcs))) {
+ /* TODO */
+ }
if (unlikely(fsize == count &&
!b_data(res) &&
h3_debug_printf(stderr, "%s\n", __func__);
- /* FIXME: no check on ALLOC ? */
- res = mux_get_buf(qcs);
+ if (!(res = qcc_get_stream_txbuf(qcs))) {
+ /* TODO */
+ }
/* h3 DATA headers : 1-byte frame type + varint frame length */
hsize = 1 + QUIC_VARINT_MAX_SIZE;
b_quic_enc_int(&pos, frm_len, 0);
b_quic_enc_int(&pos, h3c->id_goaway, 0);
- res = mux_get_buf(qcs);
+ res = qcc_get_stream_txbuf(qcs);
if (!res || b_room(res) < b_data(&pos)) {
/* Do not try forcefully to emit GOAWAY if no space left. */
TRACE_ERROR("cannot send GOAWAY", H3_EV_H3C_END, h3c->qcc->conn, qcs);
return b_data(b);
}
-static struct buffer *mux_get_buf(struct qcs *qcs)
-{
- if (!b_size(&qcs->tx.buf))
- b_alloc(&qcs->tx.buf);
-
- return &qcs->tx.buf;
-}
-
static size_t hq_interop_snd_buf(struct qcs *qcs, struct buffer *buf,
size_t count)
{
struct buffer *res, outbuf;
size_t total = 0;
- res = mux_get_buf(qcs);
+ res = qcc_get_stream_txbuf(qcs);
outbuf = b_make(b_tail(res), b_contig_space(res), 0, 0);
htx = htx_from_buf(buf);
static size_t hq_interop_nego_ff(struct qcs *qcs, size_t count)
{
- struct buffer *res = mux_get_buf(qcs);
+ struct buffer *res = qcc_get_stream_txbuf(qcs);
if (!b_room(res)) {
qcs->flags |= QC_SF_BLK_MROOM;
return b_alloc(&qcs->rx.app_buf);
}
+/* Allocate if needed and retrieve <qcs> stream buffer for data emission.
+ *
+ * Returns buffer pointer. May be NULL on allocation failure.
+ */
+struct buffer *qcc_get_stream_txbuf(struct qcs *qcs)
+{
+ return b_alloc(&qcs->tx.buf);
+}
+
/* Prepare for the emission of RESET_STREAM on <qcs> with error code <err>. */
void qcc_reset_stream(struct qcs *qcs, int err)
{