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.
This commit is contained in:
Amaury Denoyelle 2021-10-08 17:57:03 +02:00
parent 4fc8b1cb17
commit ac8ee25659

View File

@ -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);
}