]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Attach timer task to thread for the connection.
authorFrédéric Lécaille <flecaille@haproxy.com>
Thu, 9 Dec 2021 09:06:21 +0000 (10:06 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 17 Dec 2021 07:38:43 +0000 (08:38 +0100)
This is to avoid races between the connection I/O handler and this task
which share too much variables.

include/haproxy/xprt_quic-t.h
src/xprt_quic.c

index 543d670ed8a705b33464ae5fc76e84935b4bc29a..dbca9da0247a226662cb8046125801f5b1999f9a 100644 (file)
@@ -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 */
index 6556f77fa650247096d2605a4691828d55760b23..46766acb49f220867ed17db78130598f59bc185a 100644 (file)
@@ -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;