diff --git a/include/haproxy/task.h b/include/haproxy/task.h index 56fd50de6..820c2f1dd 100644 --- a/include/haproxy/task.h +++ b/include/haproxy/task.h @@ -221,6 +221,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); if (locked) HA_RWLOCK_WRLOCK(TASK_WQ_LOCK, &wq_lock); __task_unlink_wq(t); diff --git a/src/task.c b/src/task.c index 449857806..c91316cbb 100644 --- a/src/task.c +++ b/src/task.c @@ -192,6 +192,12 @@ void __task_wakeup(struct task *t, struct eb_root *root) */ void __task_queue(struct task *task, struct eb_root *wq) { +#ifdef USE_THREAD + BUG_ON((wq == &timers && !(task->state & TASK_SHARED_WQ)) || + (wq == &sched->timers && (task->state & TASK_SHARED_WQ)) || + (wq != &timers && wq != &sched->timers)); +#endif + if (likely(task_in_wq(task))) __task_unlink_wq(task);