From: William Lallemand Date: Mon, 14 Feb 2022 08:02:14 +0000 (+0100) Subject: BUG/MINOR: mworker: does not erase the pidfile upon reload X-Git-Tag: v2.6-dev2~183 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b820a6191736cdf4167d624b7bcab9957dd0697;p=thirdparty%2Fhaproxy.git BUG/MINOR: mworker: does not erase the pidfile upon reload When started in master-worker mode combined with daemon mode, HAProxy will open() with O_TRUNC the pidfile when switching to wait mode. In 2.5, it happens everytime after trying to load the configuration, since we switch to wait mode. In previous version this happens upon a failure of the configuration loading. Fixes bug #1545. Must be backported in every supported branches. --- diff --git a/src/haproxy.c b/src/haproxy.c index f10af5eae4..6f591d6fff 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -3069,7 +3069,8 @@ int main(int argc, char **argv) } /* open log & pid files before the chroot */ - if ((global.mode & MODE_DAEMON || global.mode & MODE_MWORKER) && global.pidfile != NULL) { + if ((global.mode & MODE_DAEMON || global.mode & MODE_MWORKER) && + !(global.mode & MODE_MWORKER_WAIT) && global.pidfile != NULL) { unlink(global.pidfile); pidfd = open(global.pidfile, O_CREAT | O_WRONLY | O_TRUNC, 0644); if (pidfd < 0) {