BUG/MINOR: startup: close pidfd and free global.pidfile in handle_pidfile()
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Mon, 2 Dec 2024 15:04:56 +0000 (16:04 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 5 Dec 2024 14:35:44 +0000 (15:35 +0100)
commit82c291b3b5720e3a8573c5d4e59b4a18b8aca2d8
tree0dfc4a4dff2859295cf1e161fba04d414255a9c7
parenta78b02f37d70366ef5afd308de48e8e2c4b54b4a
BUG/MINOR: startup: close pidfd and free global.pidfile in handle_pidfile()

After master-worker mode refactoring, global.pidfile is only used in
handle_pidfile(), which opens the provided file and writes the PID into it. So,
it's more appropriate to perform the close(pidfd) and ha_free(&global.pidfile)
also in this function.

This commit prepares the fix of the pidfile creation, as it's created now very
early, when we are not sure, that process has successfully started. In
master-worker mode handle_pidfile() can be called in the master process context.
So, let's make it accessible from other compilation units via global.h.

This should be backported only in 3.1.

(cherry picked from commit a33977da48978299d2d71403593846b1b21ec768)
Signed-off-by: Willy Tarreau <w@1wt.eu>
include/haproxy/global.h
src/haproxy.c