]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: task: only check TASK_WOKEN_ANY to decide to requeue a task
authorWilly Tarreau <w@1wt.eu>
Thu, 19 Dec 2019 06:34:20 +0000 (07:34 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 19 Dec 2019 13:42:22 +0000 (14:42 +0100)
After processing a task, its RUNNING bit is cleared and at the same time
we check for other bits to decide whether to requeue the task or not. It
happens that we only want to check the TASK_WOKEN_* bits, because :
  - TASK_RUNNING was just cleared
  - TASK_GLOBAL and TASK_QUEUE cannot be set yet as the task was running,
    preventing it from being requeued

It's important not to catch yet undefined flags there because it would
prevent addition of new task flags. This also shows more clearly that
waking a task up with flags 0 is not something safe to do as the task
will not be woken up if it's already running.

src/task.c

index 304e05694d01ae24bd74a2ab99baaa9fed1f7e66..7a8cf1639033fd21aa69435d4df3bb72c975c9c4 100644 (file)
@@ -482,7 +482,7 @@ void process_runnable_tasks()
                        }
 
                        state = _HA_ATOMIC_AND(&t->state, ~TASK_RUNNING);
-                       if (state)
+                       if (state & TASK_WOKEN_ANY)
                                task_wakeup(t, 0);
                        else
                                task_queue(t);