]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mworker: PROC_O_LEAVING used but not updated
authorWilliam Lallemand <wlallemand@haproxy.org>
Wed, 27 Jul 2022 09:57:12 +0000 (11:57 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Wed, 27 Jul 2022 10:13:56 +0000 (12:13 +0200)
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.

src/mworker.c

index 4da3c3e49cac0f4141ea9c0cfb029f41f203902a..6365a59cf055c86ac7cad72685cf919964270c7a 100644 (file)
@@ -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()