]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: tasks: use the local state, not t->state, to check for tasklets
authorWilly Tarreau <w@1wt.eu>
Fri, 2 May 2025 08:55:43 +0000 (10:55 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 2 May 2025 09:09:28 +0000 (11:09 +0200)
There's no point reading t->state to check for a tasklet after we've
atomically read the state into the local "state" variable. Not only it's
more expensive, it's also less clear whether that state is supposed to
be atomic or not. And in any case, tasks and tasklets have their type
forever and the one reflected in state is correct and stable.

src/task.c

index 843e467900bec46f19c553f0db62bb559ab8757f..d2c8f9b58b6bc6aa348283abcb1e3cd18ce53d2b 100644 (file)
@@ -616,7 +616,7 @@ unsigned int run_tasks_from_lists(unsigned int budgets[])
                __ha_barrier_atomic_store();
 
                /* keep the task counter up to date */
-               if (!(t->state & TASK_F_TASKLET))
+               if (!(state & TASK_F_TASKLET))
                        _HA_ATOMIC_DEC(&ha_thread_ctx[tid].tasks_in_list);
 
                /* From this point, we know that the task or tasklet was properly
@@ -628,7 +628,7 @@ unsigned int run_tasks_from_lists(unsigned int budgets[])
 
                if (unlikely((state & TASK_KILLED) || process == NULL)) {
                        /* Task or tasklet has been killed, let's remove it */
-                       if (t->state & TASK_F_TASKLET)
+                       if (state & TASK_F_TASKLET)
                                pool_free(pool_head_tasklet, t);
                        else {
                                task_unlink_wq(t);
@@ -642,7 +642,7 @@ unsigned int run_tasks_from_lists(unsigned int budgets[])
                }
 
                /* OK now the task or tasklet is well alive and is going to be run */
-               if (t->state & TASK_F_TASKLET) {
+               if (state & TASK_F_TASKLET) {
                        /* this is a tasklet */
 
                        t = process(t, ctx, state);