From: Willy Tarreau Date: Tue, 2 Mar 2021 15:26:05 +0000 (+0100) Subject: MINOR: task: add an application specific flag to the state: TASK_F_USR1 X-Git-Tag: v2.3.7~33 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=4676fa8dcd32d3384501960162b1140d5e0d2114;p=haproxy-2.3.git MINOR: task: add an application specific flag to the state: TASK_F_USR1 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. (cherry picked from commit 6fa8bcdc785c29cd3a29c14d2038f38b5547eff0) [wt: needed for upcoming fixes. task->state is 16-bit in 2.3 and before so we've reused bit 15 which was still available there. Ctx adjusments since no TASK_F_TASKLET here] Signed-off-by: Willy Tarreau --- diff --git a/include/haproxy/task-t.h b/include/haproxy/task-t.h index f37f19d..f24d9f8 100644 --- a/include/haproxy/task-t.h +++ b/include/haproxy/task-t.h @@ -55,6 +55,8 @@ TASK_WOKEN_IO|TASK_WOKEN_SIGNAL|TASK_WOKEN_MSG| \ TASK_WOKEN_RES) +#define TASK_F_USR1 0x80000 /* preserved user flag 1, application-specific, def:0 */ + enum { TL_URGENT = 0, /* urgent tasklets (I/O callbacks) */ TL_NORMAL = 1, /* normal tasks */ diff --git a/src/task.c b/src/task.c index 8689da8..20b08ea 100644 --- a/src/task.c +++ b/src/task.c @@ -450,7 +450,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_KILLED); + state = t->state & (TASK_SHARED_WQ|TASK_SELF_WAKING|TASK_HEAVY|TASK_KILLED|TASK_F_USR1); if (state & TASK_HEAVY) { /* This is a heavy task. We'll call no more than one @@ -488,7 +488,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 */