diff --git a/src/mux_quic.c b/src/mux_quic.c index f1d41d42a..5c39ef757 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -1517,6 +1517,33 @@ static void qcc_clear_frms(struct qcc *qcc) } } +/* Register stream for emission of STREAM, STOP_SENDING or RESET_STREAM. + * Set to true if stream should be emitted in priority. This is useful + * when sending STOP_SENDING or RESET_STREAM, or for emission on an application + * control stream. + */ +static void _qcc_send_stream(struct qcs *qcs, int urg) +{ + struct qcc *qcc = qcs->qcc; + + qcc_clear_frms(qcc); + + if (urg) { + /* qcc_emit_rs_ss() relies on resetted/aborted streams in send_list front. */ + BUG_ON(!(qcs->flags & (QC_SF_TO_RESET|QC_SF_TO_STOP_SENDING|QC_SF_TXBUB_OOB))); + + LIST_DEL_INIT(&qcs->el_send); + LIST_INSERT(&qcc->send_list, &qcs->el_send); + } + else { + /* Cannot send STREAM if already closed. */ + BUG_ON(qcs_is_close_local(qcs)); + + if (!LIST_INLIST(&qcs->el_send)) + LIST_APPEND(&qcs->qcc->send_list, &qcs->el_send); + } +} + /* Prepare for the emission of RESET_STREAM on with error code . */ void qcc_reset_stream(struct qcs *qcs, int err) { @@ -1555,14 +1582,13 @@ void qcc_reset_stream(struct qcs *qcs, int err) qcs_alert(qcs); } - qcc_send_stream(qcs, 1, 0); + _qcc_send_stream(qcs, 1); tasklet_wakeup(qcc->wait_event.tasklet); } -/* Register stream for emission of STREAM, STOP_SENDING or RESET_STREAM. - * Set to 1 if stream content should be treated in priority compared to - * other streams. For STREAM emission, must contains the size of the - * frame payload. This is used for flow control accounting. +/* Register stream for STREAM emission. Set to 1 if stream content + * should be treated in priority compared to other streams. must + * contains the size of the frame payload, used for flow control accounting. */ void qcc_send_stream(struct qcs *qcs, int urg, int count) { @@ -1570,22 +1596,9 @@ void qcc_send_stream(struct qcs *qcs, int urg, int count) TRACE_ENTER(QMUX_EV_QCS_SEND, qcc->conn, qcs); - /* Cannot send if already closed. */ + /* Cannot send STREAM if already closed. */ BUG_ON(qcs_is_close_local(qcs)); - - qcc_clear_frms(qcc); - - if (urg) { - /* qcc_emit_rs_ss() relies on resetted/aborted streams in send_list front. */ - BUG_ON(!(qcs->flags & (QC_SF_TO_RESET|QC_SF_TO_STOP_SENDING|QC_SF_TXBUB_OOB))); - - LIST_DEL_INIT(&qcs->el_send); - LIST_INSERT(&qcc->send_list, &qcs->el_send); - } - else { - if (!LIST_INLIST(&qcs->el_send)) - LIST_APPEND(&qcs->qcc->send_list, &qcs->el_send); - } + _qcc_send_stream(qcs, urg); if (count) { qfctl_sinc(&qcc->tx.fc, count); @@ -1608,7 +1621,7 @@ void qcc_abort_stream_read(struct qcs *qcs) TRACE_STATE("abort stream read", QMUX_EV_QCS_END, qcc->conn, qcs); qcs->flags |= (QC_SF_TO_STOP_SENDING|QC_SF_READ_ABORTED); - qcc_send_stream(qcs, 1, 0); + _qcc_send_stream(qcs, 1); tasklet_wakeup(qcc->wait_event.tasklet); end: