From 5154e7a252530e07859d14cfb7ca7bb9c5a26821 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Wed, 8 Dec 2021 14:51:04 +0100 Subject: [PATCH] MINOR: quic: notify the mux on CONNECTION_CLOSE The xprt layer is reponsible to notify the mux of a CONNECTION_CLOSE reception. In this case the flag QC_CF_CC_RECV is positionned on the qcc and the mux tasklet is waken up. One of the notable effect of the QC_CF_CC_RECV is that each qcs will be released even if they have remaining data in their send buffers. --- include/haproxy/mux_quic-t.h | 4 +++- src/mux_quic.c | 6 ++++-- src/xprt_quic.c | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/haproxy/mux_quic-t.h b/include/haproxy/mux_quic-t.h index f41918da9..eb3d6e902 100644 --- a/include/haproxy/mux_quic-t.h +++ b/include/haproxy/mux_quic-t.h @@ -22,9 +22,11 @@ enum qcs_type { QCS_MAX_TYPES }; +#define QC_CF_CC_RECV 0x00000001 + struct qcc { struct connection *conn; - uint32_t flags; + uint32_t flags; /* QC_CF_* */ struct { uint64_t max_streams; /* maximum number of concurrent streams */ diff --git a/src/mux_quic.c b/src/mux_quic.c index 9111901c4..89d7875e8 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -275,7 +275,8 @@ static int qc_release_detached_streams(struct qcc *qcc) node = eb64_next(node); if (qcs->flags & QC_SF_DETACH) { - if (!b_data(&qcs->tx.buf) && !b_data(&qcs->tx.xprt_buf)) { + if ((!b_data(&qcs->tx.buf) && !b_data(&qcs->tx.xprt_buf)) || + qcc->flags & QC_CF_CC_RECV) { qcs_destroy(qcs); release = 1; } @@ -360,7 +361,8 @@ static void qc_detach(struct conn_stream *cs) fprintf(stderr, "%s: leaving with tx.buf.data=%lu, tx.xprt_buf.data=%lu\n", __func__, b_data(&qcs->tx.buf), b_data(&qcs->tx.xprt_buf)); - if (b_data(&qcs->tx.buf) || b_data(&qcs->tx.xprt_buf)) { + if ((b_data(&qcs->tx.buf) || b_data(&qcs->tx.xprt_buf)) && + !(qcc->flags & QC_CF_CC_RECV)) { qcs->flags |= QC_SF_DETACH; return; } diff --git a/src/xprt_quic.c b/src/xprt_quic.c index 250c2b80a..6556f77fa 100644 --- a/src/xprt_quic.c +++ b/src/xprt_quic.c @@ -2326,7 +2326,9 @@ static int qc_parse_pkt_frms(struct quic_rx_packet *pkt, struct ssl_sock_ctx *ct break; case QUIC_FT_CONNECTION_CLOSE: case QUIC_FT_CONNECTION_CLOSE_APP: - /* TODO warn the mux to close the connection */ + /* warn the mux to close the connection */ + conn->qcc->flags |= QC_CF_CC_RECV; + tasklet_wakeup(conn->qcc->wait_event.tasklet); break; case QUIC_FT_HANDSHAKE_DONE: if (objt_listener(ctx->conn->target))