]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: proxy: use thread-safe stream killing on hard-stop
authorWilly Tarreau <w@1wt.eu>
Wed, 24 Feb 2021 10:08:56 +0000 (11:08 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 24 Feb 2021 10:08:56 +0000 (11:08 +0100)
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.

src/proxy.c

index 96fc1765fe542aa1fa39d275a7d0855cb687d48e..3e3d7cc23e5c3207f0f47183e0b97235f204f3d5 100644 (file)
@@ -1633,9 +1633,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));