]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MAJOR: lua: properly dequeue hlua_applet_wakeup() for new scheduler
authorWilly Tarreau <w@1wt.eu>
Fri, 21 Jul 2017 14:41:56 +0000 (16:41 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 24 Jul 2017 16:14:49 +0000 (18:14 +0200)
commitd1aa41f83b75f874d9586facc0f93ae4b1b51783
treeb633a0d9a2e11adfce3bb11d18da35cc82ec07ee
parentf1d33db10a3f726485f58b67e3cea30af250bbbc
BUG/MAJOR: lua: properly dequeue hlua_applet_wakeup() for new scheduler

The recent scheduler change broke the Lua co-sockets due to
hlua_applet_wakeup() returning NULL after waking the applet up. With the
previous scheduler, returning NULL was a way to do nothing on return.

With the new one it keeps TASK_RUNNING set, causing all new notifications
to end up into t->pending_state instead of t->state, and prevents the
task from being added into the run queue again, so and it's never woken
up anymore.

The applet keeps waking up, causing hlua_socket_handler() to do nothing
new, then si_applet_wake_cb() calling stream_int_notify() to try to wake
the task up, which it can't do due to the TASK_RUNNING flag, then decide
that since the associated task is not in the run queue, it needs to call
stream_int_update_applet() to propagate the update. This last one finds
that the applet needs to be woken up to deal with the last reported events
and calling appctx_wakeup() again. Previously, this situation didn't exist
because the task was always added in the run queue despite the TASK_RUNNING
flag.

By returning the task instead in hlua_applet_wakeup(), we can ensure its
flag is properly cleared and the task is requeued if needed or just sits
waiting for new events to happen.

This fix requires the previous ones ("BUG/MINOR: lua: always detach the
tcp/http tasks before freeing them") and MINOR: task: always preinitialize
the task's timeout in task_init().

Thanks to Thierry, Christopher and Emeric for the long head-scratching
session!

No backport is needed as the bug doesn't appear in older versions and
it's unsure whether we'll not break something by backporting it.
src/hlua.c