From 1b927eb3c35dfdbe73b4852f18e025b8e10e3716 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 15 Jul 2022 19:15:02 +0200 Subject: [PATCH] MEDIUM: proto: stop protocols under thread isolation during soft stop protocol_stop_now() is called from do_soft_stop_now() running on any thread that received the signal. The problem is that it will call some listener handlers to close the FD, resulting in an fd_delete() being called from the wrong group. That's not clean and we cannot even rely on the thread mask to show up. One interesting long-term approach could be to have kill queues for FDs, and maybe we'll need them in the long run. However that doesn't work well for listeners in this situation. Let's simply isolate ourselves during this instant. We know we'll be alone dealing with the close and that the FD will be instantly deleted since not in use by any other thread. It's not the cleanest solution but it should last long enough without causing trouble. --- src/proxy.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/proxy.c b/src/proxy.c index 7c07321276..e38970106d 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -2198,9 +2198,14 @@ static void do_soft_stop_now() } } + /* we isolate so that we have a chance of stopping listeners in other groups */ + thread_isolate(); + /* stop all stoppable listeners */ protocol_stop_now(); + thread_release(); + /* signal zero is used to broadcast the "stopping" event */ signal_handler(0); } -- 2.39.5