Skip to content

Commit 1cae481

Browse files
committed
MINOR: mux-quic: simplify empty emitted STREAM FIN handling
An empty STREAM frame can be emitted by QUIC MUX to notify about a delayed FIN. This requires tedious comparison in qmux_ctrl_send() to differentiate between the first empty frame and a retransmitted one. Simplify this by unsubscribe from streamdesc layer when the QCS is locally closed after FIN transmission. This prevents all future retransmitted frames to be notify to the QCS instance, especially any retransmitted empty FIN.
1 parent af1d170 commit 1cae481

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/mux_quic.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,15 +563,19 @@ static void qmux_ctrl_send(struct qc_stream_desc *stream, uint64_t data, uint64_
563563
/* Real off MUST always be the greatest offset sent. */
564564
BUG_ON(offset > qcs->tx.fc.off_real);
565565

566-
/* check if the STREAM frame has already been notified. It can happen
567-
* for retransmission. Special care must be taken to ensure an empty
568-
* STREAM frame with FIN set is not considered as retransmitted
566+
/* Check if the STREAM frame has already been notified. An empty FIN
567+
* frame must not be considered retransmitted.
569568
*/
570-
if (offset + data < qcs->tx.fc.off_real || (!data && !(qcs->flags & QC_SF_FIN_STREAM))) {
569+
if (data && offset + data <= qcs->tx.fc.off_real) {
571570
TRACE_DEVEL("offset already notified", QMUX_EV_QCS_SEND, qcc->conn, qcs);
572571
goto out;
573572
}
574573

574+
/* An empty STREAM frame is only used to notify FIN. A retransmitted
575+
* empty FIN cannot be notified as QCS will be unsubscribed first.
576+
*/
577+
BUG_ON(!data && !(qcs->flags & QC_SF_FIN_STREAM));
578+
575579
qcs_idle_open(qcs);
576580

577581
diff = offset + data - qcs->tx.fc.off_real;
@@ -622,6 +626,9 @@ static void qmux_ctrl_send(struct qc_stream_desc *stream, uint64_t data, uint64_
622626
/* Reset flag to not emit multiple FIN STREAM frames. */
623627
qcs->flags &= ~QC_SF_FIN_STREAM;
624628
}
629+
630+
/* Unsubscribe from streamdesc when everything sent. */
631+
qc_stream_desc_sub_send(qcs->stream, NULL);
625632
}
626633
}
627634

0 commit comments

Comments
 (0)