diff --git a/include/haproxy/listener-t.h b/include/haproxy/listener-t.h index 0f6adde3a..f45c990a5 100644 --- a/include/haproxy/listener-t.h +++ b/include/haproxy/listener-t.h @@ -246,7 +246,7 @@ struct listener { struct eb32_node id; /* place in the tree of used IDs */ } conf; /* config information */ - struct li_per_thread *per_thr; /* per-thread fields */ + struct li_per_thread *per_thr; /* per-thread fields (one per thread in the group) */ EXTRA_COUNTERS(extra_counters); }; diff --git a/src/listener.c b/src/listener.c index ad72c8ecc..d6e58ce69 100644 --- a/src/listener.c +++ b/src/listener.c @@ -205,19 +205,21 @@ REGISTER_POST_DEINIT(accept_queue_deinit); #endif // USE_THREAD -/* Memory allocation and initialization of the per_thr field. +/* Memory allocation and initialization of the per_thr field (one entry per + * bound thread). * Returns 0 if the field has been successfully initialized, -1 on failure. */ int li_init_per_thr(struct listener *li) { + int nbthr = MIN(global.nbthread, MAX_THREADS_PER_GROUP); int i; /* allocate per-thread elements for listener */ - li->per_thr = calloc(global.nbthread, sizeof(*li->per_thr)); + li->per_thr = calloc(nbthr, sizeof(*li->per_thr)); if (!li->per_thr) return -1; - for (i = 0; i < global.nbthread; ++i) { + for (i = 0; i < nbthr; ++i) { MT_LIST_INIT(&li->per_thr[i].quic_accept.list); MT_LIST_INIT(&li->per_thr[i].quic_accept.conns); diff --git a/src/quic_sock.c b/src/quic_sock.c index d7d40982e..196ad386d 100644 --- a/src/quic_sock.c +++ b/src/quic_sock.c @@ -147,7 +147,7 @@ int quic_sock_accepting_conn(const struct receiver *rx) struct connection *quic_sock_accept_conn(struct listener *l, int *status) { struct quic_conn *qc; - struct li_per_thread *lthr = &l->per_thr[tid]; + struct li_per_thread *lthr = &l->per_thr[ti->ltid]; qc = MT_LIST_POP(<hr->quic_accept.conns, struct quic_conn *, accept_list); if (!qc || qc->flags & (QUIC_FL_CONN_CLOSING|QUIC_FL_CONN_DRAINING)) @@ -897,7 +897,7 @@ struct quic_accept_queue *quic_accept_queues; void quic_accept_push_qc(struct quic_conn *qc) { struct quic_accept_queue *queue = &quic_accept_queues[tid]; - struct li_per_thread *lthr = &qc->li->per_thr[tid]; + struct li_per_thread *lthr = &qc->li->per_thr[ti->ltid]; /* early return if accept is already in progress/done for this * connection