From 20b7afbc14ca11c55919155e0b3d0d9aed33b9ab Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 28 Sep 2015 16:35:04 +0200 Subject: [PATCH] BUG/MEDIUM: proxy: do not wake stopped proxies' tasks during soft_stop() When performing a soft stop, we used to wake up every proxy's task and each of their table's task. The problem is that since we're able to stop proxies and peers not bound to a specific process, we may end up calling random junk by doing so of the proxy we're waking up is already stopped. This causes a segfault to appear during soft reloads for old processes not bound to a peers section if such a section exists in other processes. Let's only consider proxies that are not stopped when doing this. This fix must be backported to 1.5 which also has the same issue. --- src/proxy.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/proxy.c b/src/proxy.c index 1f2fc5615..194d4bdf6 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -925,13 +925,16 @@ void soft_stop(void) Warning("Stopping %s %s in %d ms.\n", proxy_cap_str(p->cap), p->id, p->grace); send_log(p, LOG_WARNING, "Stopping %s %s in %d ms.\n", proxy_cap_str(p->cap), p->id, p->grace); p->stop_time = tick_add(now_ms, p->grace); - } - if (p->table.size && p->table.sync_task) - task_wakeup(p->table.sync_task, TASK_WOKEN_MSG); - /* wake every proxy task up so that they can handle the stopping */ - if (p->task) - task_wakeup(p->task, TASK_WOKEN_MSG); + /* Note: do not wake up stopped proxies' task nor their tables' + * tasks as these ones might point to already released entries. + */ + if (p->table.size && p->table.sync_task) + task_wakeup(p->table.sync_task, TASK_WOKEN_MSG); + + if (p->task) + task_wakeup(p->task, TASK_WOKEN_MSG); + } p = p->next; }