From ac8ee256598487f695fc0b18c991001059e8bb19 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Fri, 8 Oct 2021 17:57:03 +0200 Subject: [PATCH] MINOR: mux-quic: implement standard method to detect if qcc is dead For the moment, a quic connection is considered dead if it has no bidirectional streams left on it. This test is implemented via qcc_is_dead function. It can be reused to properly close the connection when needed. --- src/mux_quic.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mux_quic.c b/src/mux_quic.c index d16fd9777..578a59eeb 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -344,6 +344,7 @@ static inline int qcc_may_expire(const struct qcc *qcc) static __inline int qcc_is_dead(const struct qcc *qcc) { +#if 0 if (eb_is_empty(&qcc->streams_by_id) && /* don't close if streams exist */ ((qcc->conn->flags & CO_FL_ERROR) || /* errors close immediately */ (qcc->st0 >= QC_CS_ERROR && !qcc->task) || /* a timeout stroke earlier */ @@ -351,6 +352,9 @@ qcc_is_dead(const struct qcc *qcc) (!br_data(qcc->mbuf) && /* mux buffer empty, also process clean events below */ conn_xprt_read0_pending(qcc->conn)))) return 1; +#endif + if (!qcc->strms[QCS_CLT_BIDI].nb_streams) + return 1; return 0; } @@ -1561,7 +1565,7 @@ static void qc_detach(struct conn_stream *cs) TRACE_ENTER(QC_EV_STRM_END, qcs ? qcs->qcc->conn : NULL, qcs); qcs_destroy(qcs); - if (!qcc->strms[QCS_CLT_BIDI].nb_streams) + if (qcc_is_dead(qcc)) qc_release(qcc); TRACE_LEAVE(QC_EV_STRM_END, qcs ? qcs->qcc->conn : NULL); }