MINOR: mux-quic: rename stream purge function

Rename qc_release_detached_streams() to qc_purge_streams(). The aim is
to have a more generic name. It's expected to complete this function to
add other criteria to purge dead streams.

Also the function documentation has been corrected. It does not return a
number of streams. Instead it is a boolean value, to true if at least
one stream was released.
This commit is contained in:
Amaury Denoyelle 2022-07-08 14:04:21 +02:00
parent b143723411
commit c1a6dfd477

View File

@ -1341,34 +1341,39 @@ static int qc_recv(struct qcc *qcc)
return 0; return 0;
} }
/* Release all streams that are already marked as detached. This is only done
* if their TX buffers are empty or if a CONNECTION_CLOSE has been received. /* Release all streams which have their transfer operation achieved.
* *
* Return the number of released stream. * Returns true if at least one stream is released.
*/ */
static int qc_release_detached_streams(struct qcc *qcc) static int qc_purge_streams(struct qcc *qcc)
{ {
struct eb64_node *node; struct eb64_node *node;
int release = 0; int release = 0;
TRACE_ENTER(QMUX_EV_QCC_WAKE);
node = eb64_first(&qcc->streams_by_id); node = eb64_first(&qcc->streams_by_id);
while (node) { while (node) {
struct qcs *qcs = eb64_entry(node, struct qcs, by_id); struct qcs *qcs = eb64_entry(node, struct qcs, by_id);
node = eb64_next(node); node = eb64_next(node);
/* Release detached streams with empty buffer. */
if (qcs->flags & QC_SF_DETACH) { if (qcs->flags & QC_SF_DETACH) {
if (!b_data(&qcs->tx.buf) && if (!b_data(&qcs->tx.buf) &&
qcs->tx.offset == qcs->tx.sent_offset) { qcs->tx.offset == qcs->tx.sent_offset) {
TRACE_DEVEL("purging detached stream", QMUX_EV_QCC_WAKE, qcs->qcc->conn, qcs);
qcs_destroy(qcs); qcs_destroy(qcs);
release = 1; release = 1;
continue;
} }
else {
qcc->conn->xprt->subscribe(qcc->conn, qcc->conn->xprt_ctx, qcc->conn->xprt->subscribe(qcc->conn, qcc->conn->xprt_ctx,
SUB_RETRY_SEND, &qcc->wait_event); SUB_RETRY_SEND, &qcc->wait_event);
} }
} }
}
TRACE_LEAVE(QMUX_EV_QCC_WAKE);
return release; return release;
} }
@ -1380,7 +1385,7 @@ static struct task *qc_io_cb(struct task *t, void *ctx, unsigned int status)
qc_send(qcc); qc_send(qcc);
if (qc_release_detached_streams(qcc)) { if (qc_purge_streams(qcc)) {
if (qcc_is_dead(qcc)) { if (qcc_is_dead(qcc)) {
qc_release(qcc); qc_release(qcc);
} }