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);
};
#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);
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))
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