]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: tasks: use MT_LIST_ADDQ() when killing tasks.
authorWilly Tarreau <w@1wt.eu>
Fri, 10 Jul 2020 06:32:10 +0000 (08:32 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 10 Jul 2020 06:52:13 +0000 (08:52 +0200)
A bug in task_kill() was fixed by commy 54d31170a ("BUG/MAJOR: sched:
make sure task_kill() always queues the task") which added a list
initialization before adding an element. But in fact an inconditional
addition would have done the same and been simpler than first
initializing then checking the element was initialized. Let's use
MT_LIST_ADDQ() there to add the task to kill into the shared queue
and kill the dirty LIST_INIT().

src/task.c

index 102462eb8fefdf0508ad918b837da26b68da972e..ea3d80830864464758bc47ff264184134bc0da55 100644 (file)
@@ -96,8 +96,7 @@ void task_kill(struct task *t)
                        thr = my_ffsl(t->thread_mask) - 1;
 
                        /* Beware: tasks that have never run don't have their ->list empty yet! */
-                       LIST_INIT(&((struct tasklet *)t)->list);
-                       MT_LIST_TRY_ADDQ(&task_per_thread[thr].shared_tasklet_list,
+                       MT_LIST_ADDQ(&task_per_thread[thr].shared_tasklet_list,
                                     (struct mt_list *)&((struct tasklet *)t)->list);
                        _HA_ATOMIC_ADD(&tasks_run_queue, 1);
                        _HA_ATOMIC_ADD(&task_per_thread[thr].task_list_size, 1);