From be9833e3248c84d3a911c215125975003c29d688 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 24 Feb 2021 11:08:56 +0100 Subject: [PATCH] BUG/MEDIUM: proxy: use thread-safe stream killing on hard-stop When setting hard-stop-after, hard_stop() is called at the end to kill last pending streams. Unfortunately there's no locking there while walking over the streams list nor when shutting them down, so it's very likely that some old processes have been crashing or gone wild due to this. Let's use a thread_isolate() call for this as we don't have much other choice (and it happens once in the process' life, that's OK). This must be backported to 1.8. (cherry picked from commit 92b887e20a995323d3fbd42d2be035733cefd6ba) Signed-off-by: Christopher Faulet --- src/proxy.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/proxy.c b/src/proxy.c index e469c76..b29bd96 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -1213,9 +1213,12 @@ struct task *hard_stop(struct task *t, void *context, unsigned short state) } p = p->next; } + + thread_isolate(); list_for_each_entry(s, &streams, list) { stream_shutdown(s, SF_ERR_KILLED); } + thread_release(); killed = 1; t->expire = tick_add(now_ms, MS_TO_TICKS(1000)); -- 1.7.10.4