From: William Lallemand Date: Wed, 27 Jul 2022 09:57:12 +0000 (+0200) Subject: BUG/MINOR: mworker: PROC_O_LEAVING used but not updated X-Git-Tag: v2.7-dev3~60 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14b98ef1bde442abb2f3616a590af803516c7467;p=thirdparty%2Fhaproxy.git BUG/MINOR: mworker: PROC_O_LEAVING used but not updated Since commit 2be557f ("MEDIUM: mworker: seamless reload use the internal sockpair"), we are using the PROC_O_LEAVING flag to determine which sockpair worker will be used with -x during the next reload. However in mworker_reexec(), the PROC_O_LEAVING flag is not updated, it is only updated at startup in mworker_env_to_proc_list(). This could be a problem when a remaining process is still in the list, it could be selected as the current worker, and its socket will be used even if _getsocks doesn't work anymore on it. (bug #1803) This patch fixes the issue by updating the PROC_O_LEAVING flag in mworker_proc_list_to_env() just before using it in mworker_reexec() Must be backported to 2.6. --- diff --git a/src/mworker.c b/src/mworker.c index 4da3c3e49c..6365a59cf0 100644 --- a/src/mworker.c +++ b/src/mworker.c @@ -110,6 +110,7 @@ void mworker_proc_list_to_env() { char *msg = NULL; struct mworker_proc *child; + int minreloads = INT_MAX; /* minimum number of reloads to chose which processes are "current" ones */ list_for_each_entry(child, &proc_list, list) { char type = '?'; @@ -121,11 +122,22 @@ void mworker_proc_list_to_env() else if (child->options &= PROC_O_TYPE_WORKER) type = 'w'; + if (child->reloads < minreloads) + minreloads = child->reloads; + if (child->pid > -1) memprintf(&msg, "%s|type=%c;fd=%d;pid=%d;reloads=%d;failedreloads=%d;timestamp=%d;id=%s;version=%s", msg ? msg : "", type, child->ipc_fd[0], child->pid, child->reloads, child->failedreloads, child->timestamp, child->id ? child->id : "", child->version); } if (msg) setenv("HAPROXY_PROCESSES", msg, 1); + + list_for_each_entry(child, &proc_list, list) { + if (child->reloads > minreloads && !(child->options & PROC_O_TYPE_MASTER)) { + child->options |= PROC_O_LEAVING; + } + } + + } struct mworker_proc *mworker_proc_new()