mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-20 12:40:46 +00:00
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.
This commit is contained in:
parent
3d550848be
commit
b30247b16c
@ -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;
|
||||
|
@ -1926,6 +1926,30 @@ static int qc_purge_streams(struct qcc *qcc)
|
||||
return release;
|
||||
}
|
||||
|
||||
/* 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_shutdown(struct qcc *qcc)
|
||||
{
|
||||
TRACE_ENTER(QMUX_EV_QCC_END, qcc->conn);
|
||||
|
||||
if (qcc->flags & QC_CF_APP_SHUT)
|
||||
goto out;
|
||||
|
||||
if (qcc->app_ops && qcc->app_ops->shutdown) {
|
||||
qcc->app_ops->shutdown(qcc->ctx);
|
||||
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.
|
||||
*/
|
||||
@ -1936,20 +1960,7 @@ static void qc_release(struct qcc *qcc)
|
||||
|
||||
TRACE_ENTER(QMUX_EV_QCC_END, conn);
|
||||
|
||||
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);
|
||||
}
|
||||
qc_shutdown(qcc);
|
||||
|
||||
if (qcc->task) {
|
||||
task_destroy(qcc->task);
|
||||
|
Loading…
Reference in New Issue
Block a user