]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: task: add an application specific flag to the state: TASK_F_USR1
authorWilly Tarreau <w@1wt.eu>
Tue, 2 Mar 2021 15:26:05 +0000 (16:26 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 5 Mar 2021 07:30:08 +0000 (08:30 +0100)
This flag will be usable by any application. It will be preserved across
wakeups so the application can use it to do various stuff. Some I/O
handlers will soon benefit from this.

include/haproxy/task-t.h
src/task.c

index 5debef652f6cd3f1da27a9bd597a67dad68ab1e0..62252e748f10f0f5c03db2062df880c682d5ece4 100644 (file)
@@ -56,7 +56,8 @@
                            TASK_WOKEN_RES)
 
 #define TASK_F_TASKLET    0x00008000  /* nature of this task: 0=task 1=tasklet */
-/* unused: 0x10000..0x80000000 */
+#define TASK_F_USR1       0x00010000  /* preserved user flag 1, application-specific, def:0 */
+/* unused: 0x20000..0x80000000 */
 
 
 enum {
index a99d30ab62307c4e6b0bbbe57668b3ff1a4ef2cd..bc8ecf4cfdf918a1c577ad8855f9dd42a55e58e4 100644 (file)
@@ -487,7 +487,7 @@ unsigned int run_tasks_from_lists(unsigned int budgets[])
 
                budgets[queue]--;
                t = (struct task *)LIST_ELEM(tl_queues[queue].n, struct tasklet *, list);
-               state = t->state & (TASK_SHARED_WQ|TASK_SELF_WAKING|TASK_HEAVY|TASK_F_TASKLET|TASK_KILLED);
+               state = t->state & (TASK_SHARED_WQ|TASK_SELF_WAKING|TASK_HEAVY|TASK_F_TASKLET|TASK_KILLED|TASK_F_USR1);
 
                ti->flags &= ~TI_FL_STUCK; // this thread is still running
                activity[tid].ctxsw++;
@@ -533,7 +533,7 @@ unsigned int run_tasks_from_lists(unsigned int budgets[])
 
                LIST_DEL_INIT(&((struct tasklet *)t)->list);
                __ha_barrier_store();
-               state = _HA_ATOMIC_XCHG(&t->state, state | TASK_RUNNING);
+               state = _HA_ATOMIC_XCHG(&t->state, state|TASK_RUNNING|TASK_F_USR1);
                __ha_barrier_atomic_store();
 
                /* OK then this is a regular task */