]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: task: always ensure that the run queue is consistent
authorWilly Tarreau <w@1wt.eu>
Mon, 23 Feb 2015 15:07:01 +0000 (16:07 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 23 Feb 2015 15:07:01 +0000 (16:07 +0100)
commit501260bf67eab7ed0703aa47d2c61bcfd1ada69e
treed9399b6035c8d8796ced36d14fd39a6337c67f00
parent70fd7480f9919b1b43abf9e169cccf29d07a8c47
MEDIUM: task: always ensure that the run queue is consistent

As found by Thierry Fournier, if a task manages to kill another one and
if this other task is the next one in the run queue, we can do whatever
including crashing, because the scheduler restarts from the saved next
task. For now, there is no such concept of a task killing another one,
but with Lua it will come.

A solution consists in always performing the lookup of the first task in
the scheduler's loop, but it's expensive and costs around 2% of the
performance.

Another solution consists in keeping a global next run queue node and
ensuring that when this task gets removed, it updates this pointer to
the next one. This allows to simplify the code a bit and in the end to
slightly increase the performance (0.3-0.5%). The mechanism might still
be usable if we later migrate to a multi-threaded scheduler.
include/proto/task.h
src/task.c