From: Frédéric Lécaille Date: Thu, 9 Dec 2021 09:06:21 +0000 (+0100) Subject: MINOR: quic: Attach timer task to thread for the connection. X-Git-Tag: v2.6-dev1~279 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f57c333ac1b9e496066afaddf2d113ffcc54a204;p=thirdparty%2Fhaproxy.git MINOR: quic: Attach timer task to thread for the connection. This is to avoid races between the connection I/O handler and this task which share too much variables. --- diff --git a/include/haproxy/xprt_quic-t.h b/include/haproxy/xprt_quic-t.h index 543d670ed8..dbca9da024 100644 --- a/include/haproxy/xprt_quic-t.h +++ b/include/haproxy/xprt_quic-t.h @@ -627,7 +627,8 @@ struct quic_conn { uint32_t version; /* QUIC transport parameters TLS extension */ int tps_tls_ext; - + /* Thread ID this connection is attached to */ + int tid; int state; uint64_t err_code; unsigned char enc_params[QUIC_TP_MAX_ENCLEN]; /* encoded QUIC transport parameters */ diff --git a/src/xprt_quic.c b/src/xprt_quic.c index 6556f77fa6..46766acb49 100644 --- a/src/xprt_quic.c +++ b/src/xprt_quic.c @@ -3424,7 +3424,8 @@ static struct quic_conn *qc_new_conn(unsigned int version, int ipv4, */ static int quic_conn_init_timer(struct quic_conn *qc) { - qc->timer_task = task_new_anywhere(); + /* Attach this task to the same thread ID used for the connection */ + qc->timer_task = task_new(1UL << qc->tid); if (!qc->timer_task) return 0; @@ -5066,7 +5067,7 @@ static int qc_conn_init(struct connection *conn, void **xprt_ctx) struct bind_conf *bc = __objt_listener(conn->target)->bind_conf; struct quic_conn *qc = ctx->conn->qc; - ctx->wait_event.tasklet->tid = quic_get_cid_tid(&qc->scid); + qc->tid = ctx->wait_event.tasklet->tid = quic_get_cid_tid(&qc->scid); if (qc_ssl_sess_init(qc, bc->initial_ctx, &ctx->ssl, qc->enc_params, qc->enc_params_len) == -1) goto err;