CLEANUP: task: move the tree root detection from __task_wakeup() to task_wakeup()
Historically we used to call __task_wakeup() with a known tree root but
this is not the case and the code has remained needlessly complicated
with the root calculation in task_wakeup() passed in argument to
__task_wakeup() which compares it again.
Let's get rid of this and just move the detection code there. This
eliminates some ifdefs and allows to simplify the test conditions quite
a bit.
diff --git a/src/task.c b/src/task.c
index 0287817..1d1e63c 100644
--- a/src/task.c
+++ b/src/task.c
@@ -115,14 +115,16 @@
* The task must not already be in the run queue. If unsure, use the safer
* task_wakeup() function.
*/
-void __task_wakeup(struct task *t, struct eb_root *root)
+void __task_wakeup(struct task *t)
{
+ struct eb_root *root = &sched->rqueue;
+
#ifdef USE_THREAD
- if (root == &rqueue) {
+ if (t->thread_mask != tid_bit && global.nbthread != 1) {
+ root = &rqueue;
+
HA_SPIN_LOCK(TASK_RQ_LOCK, &rq_lock);
- }
- if (root == &rqueue) {
global_tasks_mask |= t->thread_mask;
grq_total++;
t->rq.key = ++global_rqueue_ticks;
@@ -146,6 +148,7 @@
t->call_date = now_mono_time();
eb32sc_insert(root, &t->rq, t->thread_mask);
+
#ifdef USE_THREAD
if (root == &rqueue) {
_HA_ATOMIC_OR(&t->state, TASK_GLOBAL);