]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: tasks: Add __task_get_new_tid_field()
authorOlivier Houchard <ohouchard@haproxy.com>
Tue, 28 Apr 2026 16:09:32 +0000 (18:09 +0200)
committerOlivier Houchard <cognet@ci0.org>
Fri, 12 Jun 2026 09:49:09 +0000 (11:49 +0200)
Introduce __task_get_new_tid_field(), that provides the tid to be used
for a task.
For shared task, to mark temporary ownership of a task, instead of -1,
the tid will be set to -2-tid, tid being the tid of the current thread.

include/haproxy/task.h

index c5c0c1eb6a27e8f291c2606e984fa21911d5ea95..df4b42ea5ba65bfe5340512d38d015b4323b9fc8 100644 (file)
@@ -262,6 +262,13 @@ static inline int __task_set_state_and_tid(struct task *t, int expected_tid, int
 #endif
 }
 
+static inline int __task_get_new_tid_field(int curtid)
+{
+       if (curtid >= 0 || curtid < -1)
+               return curtid;
+       return -2 - tid;
+}
+
 /* puts the task <t> in run queue with reason flags <f>, and returns <t> */
 /* This will put the task in the local runqueue if the task is only runnable
  * by the current thread, in the global runqueue otherwies. With DEBUG_TASK,