]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: stream: make stream_shutdown() async-safe
authorWilly Tarreau <w@1wt.eu>
Thu, 26 Sep 2024 16:30:36 +0000 (18:30 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 27 Sep 2024 10:15:41 +0000 (12:15 +0200)
commitb8e3b0a18d59b4f52b4ecb7ae61cef0b8b2402a0
tree9a77fcaea4cdd82bd596c3118f7e633ecd2e859c
parentb5281283bb00248152ba361f8d7306b37febbee0
BUG/MEDIUM: stream: make stream_shutdown() async-safe

The solution found in commit b500e84e24 ("BUG/MINOR: server: shut down
streams under thread isolation") to deal with inter-thread stream
shutdown doesn't work fine because there exists code paths involving
a server lock which can then deadlock on thread_isolate(). A better
solution then consists in deferring the shutdown to the stream itself
and just wake it up for that.

The only thing is that TASK_WOKEN_OTHER is a bit too generic and we
need to pass at least 2 types of events (SF_ERR_DOWN and SF_ERR_KILLED),
so we're now leveraging the new TASK_F_UEVT1 and _UEVT2 flags on the
task's state to convey these info. The caller only needs to wake the
task up with these flags set, and the stream handler will then finish
the job locally using stream_shutdown_self().

This needs to be carefully backported to all branches affected by the
dequeuing issue and containing any of the 5541d4995d ("BUG/MEDIUM:
queue: deal with a rare TOCTOU in assign_server_and_queue()"), and/or
b11495652e ("BUG/MEDIUM: queue: implement a flag to check for the
dequeuing").
include/haproxy/stream.h
src/stream.c