MEDIUM: mux-quic: defer stream shut if remaining tx data
Defer the shutting of a qcs if there is still data in its tx buffers. In
this case, the conn_stream is closed but the qcs is kept with a new flag
QC_SF_DETACH.
On ACK reception, the xprt wake up the shut_tl tasklet if the stream is
flagged with QC_SF_DETACH. This tasklet is responsible to free the qcs
and possibly the qcc when all bidirectional streams are removed.
diff --git a/src/mux_quic.c b/src/mux_quic.c
index 578a59e..df6d147 100644
--- a/src/mux_quic.c
+++ b/src/mux_quic.c
@@ -1564,9 +1564,16 @@
struct qcc *qcc = qcs->qcc;
TRACE_ENTER(QC_EV_STRM_END, qcs ? qcs->qcc->conn : NULL, qcs);
+ if (b_data(&qcs->tx.buf) || b_data(&qcs->tx.xprt_buf)) {
+ qcs->flags |= QC_SF_DETACH;
+ goto out;
+ }
+
qcs_destroy(qcs);
if (qcc_is_dead(qcc))
qc_release(qcc);
+
+ out:
TRACE_LEAVE(QC_EV_STRM_END, qcs ? qcs->qcc->conn : NULL);
}
@@ -1603,7 +1610,8 @@
TRACE_ENTER(QC_EV_STRM_SHUT, qcc->conn, qcs);
- if (qcs->flags & QC_SF_NOTIFIED) {
+ if (qcs->flags & QC_SF_NOTIFIED ||
+ (b_data(&qcs->tx.buf) || b_data(&qcs->tx.xprt_buf))) {
/* some data processing remains to be done first */
goto end;
}