]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mworker: don't use unitialized mworker_proc struct
authorWilliam Lallemand <wlallemand@haproxy.com>
Fri, 14 Dec 2018 18:31:21 +0000 (19:31 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 14 Dec 2018 18:41:38 +0000 (19:41 +0100)
If the reload fail after the parsing of the configuration, the
mworker_proc structures are created for the processes it tried to
create.

The mworker_proc_list_to_env() function was exporting these unitialized
structures in the "HAPROXY_PROCESSES" environment variable which was
leading to this kind of output in "show proc":

4294967295      worker          [was: 1]        1               17879d 16h26m28s

src/haproxy.c

index 0fa07ce4e66fc4124d56531d3336f1a4cc2e0cfb..20fc1dece711061402053d5bc294672de1932887 100644 (file)
@@ -540,7 +540,8 @@ static void mworker_proc_list_to_env()
        struct mworker_proc *child;
 
        list_for_each_entry(child, &proc_list, list) {
-               memprintf(&msg, "%s|type=%c;fd=%d;pid=%d;rpid=%d;reloads=%d;timestamp=%d", msg ? msg : "", child->type, child->ipc_fd[0], child->pid, child->relative_pid, child->reloads, child->timestamp);
+               if (child->pid > -1)
+                       memprintf(&msg, "%s|type=%c;fd=%d;pid=%d;rpid=%d;reloads=%d;timestamp=%d", msg ? msg : "", child->type, child->ipc_fd[0], child->pid, child->relative_pid, child->reloads, child->timestamp);
        }
        if (msg)
                setenv("HAPROXY_PROCESSES", msg, 1);