From: Amaury Denoyelle Date: Tue, 24 Jan 2023 17:18:23 +0000 (+0100) Subject: MINOR: mux-quic: define qc_shutdown() X-Git-Tag: v2.8-dev5~164 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b30247b16cde194b7a92fa6e99f6606d562f53c6;p=thirdparty%2Fhaproxy.git MINOR: mux-quic: define qc_shutdown() Factorize shutdown operation in a dedicated function qc_shutdown(). This will allow to call it from multiple places. A new flag QC_CF_APP_SHUT is also defined to ensure it will only be executed once even if called multiple times per connection. This commit will be useful to properly support haproxy soft stop. This should be backported up to 2.7. --- diff --git a/include/haproxy/mux_quic-t.h b/include/haproxy/mux_quic-t.h index 2141506feb..2c66f85f58 100644 --- a/include/haproxy/mux_quic-t.h +++ b/include/haproxy/mux_quic-t.h @@ -30,6 +30,7 @@ enum qcs_type { #define QC_CF_CC_EMIT 0x00000001 /* A CONNECTION_CLOSE is set by the MUX */ #define QC_CF_BLK_MFCTL 0x00000002 /* sending blocked due to connection flow-control */ #define QC_CF_CONN_FULL 0x00000004 /* no stream buffers available on connection */ +#define QC_CF_APP_SHUT 0x00000008 /* Application layer shutdown done. */ struct qcc { struct connection *conn; diff --git a/src/mux_quic.c b/src/mux_quic.c index 8577debd3f..125d2984e5 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -1926,31 +1926,42 @@ static int qc_purge_streams(struct qcc *qcc) return release; } -/* release function. This one should be called to free all resources allocated - * to the mux. +/* Execute application layer shutdown. If this operation is not defined, a + * CONNECTION_CLOSE will be prepared as a fallback. This function is protected + * against multiple invocation with the flag QC_CF_APP_SHUT. */ -static void qc_release(struct qcc *qcc) +static void qc_shutdown(struct qcc *qcc) { - struct connection *conn = qcc->conn; - struct eb64_node *node; + TRACE_ENTER(QMUX_EV_QCC_END, qcc->conn); - TRACE_ENTER(QMUX_EV_QCC_END, conn); + if (qcc->flags & QC_CF_APP_SHUT) + goto out; if (qcc->app_ops && qcc->app_ops->shutdown) { - /* Application protocol with dedicated connection closing - * procedure. - */ qcc->app_ops->shutdown(qcc->ctx); - - /* useful if application protocol should emit some closing - * frames. For example HTTP/3 GOAWAY frame. - */ qc_send(qcc); } else { qcc_emit_cc_app(qcc, QC_ERR_NO_ERROR, 0); } + out: + qcc->flags |= QC_CF_APP_SHUT; + TRACE_LEAVE(QMUX_EV_QCC_END, qcc->conn); +} + +/* release function. This one should be called to free all resources allocated + * to the mux. + */ +static void qc_release(struct qcc *qcc) +{ + struct connection *conn = qcc->conn; + struct eb64_node *node; + + TRACE_ENTER(QMUX_EV_QCC_END, conn); + + qc_shutdown(qcc); + if (qcc->task) { task_destroy(qcc->task); qcc->task = NULL;