From 5b8e0547320d3255d0d7366c57ec777e9bc2d1a8 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 15 Jun 2022 14:24:57 +0200 Subject: [PATCH] MEDIUM: task/debug: move the ->thread_mask integrity checks to ->tid Let's make sure the new ->tid field is always correct instead of checking the thread mask. --- include/haproxy/applet.h | 2 +- include/haproxy/task.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/haproxy/applet.h b/include/haproxy/applet.h index 84619de48..68f98e2e3 100644 --- a/include/haproxy/applet.h +++ b/include/haproxy/applet.h @@ -70,7 +70,7 @@ static inline int appctx_init(struct appctx *appctx) * the appctx will be fully initialized. The session and the stream will * eventually be created. The affinity must be set now ! */ - BUG_ON((appctx->t->thread_mask & tid_bit) == 0); + BUG_ON(appctx->t->tid != tid); task_set_affinity(appctx->t, tid_bit); if (appctx->applet->init) diff --git a/include/haproxy/task.h b/include/haproxy/task.h index d5458bfd6..2d86452db 100644 --- a/include/haproxy/task.h +++ b/include/haproxy/task.h @@ -279,7 +279,7 @@ static inline struct task *task_unlink_wq(struct task *t) if (likely(task_in_wq(t))) { locked = t->state & TASK_SHARED_WQ; - BUG_ON(!locked && t->thread_mask != tid_bit); + BUG_ON(!locked && t->tid != tid); if (locked) HA_RWLOCK_WRLOCK(TASK_WQ_LOCK, &wq_lock); __task_unlink_wq(t); @@ -318,7 +318,7 @@ static inline void task_queue(struct task *task) } else #endif { - BUG_ON(task->thread_mask != tid_bit); // should have TASK_SHARED_WQ + BUG_ON(task->tid != tid); // should have TASK_SHARED_WQ if (!task_in_wq(task) || tick_is_lt(task->expire, task->wq.key)) __task_queue(task, &th_ctx->timers); } @@ -731,7 +731,7 @@ static inline void task_schedule(struct task *task, int when) } else #endif { - BUG_ON((task->thread_mask & tid_bit) == 0); // should have TASK_SHARED_WQ + BUG_ON(task->tid != tid); if (task_in_wq(task)) when = tick_first(when, task->expire);