]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: init: split the early initialization in its own function
authorWilly Tarreau <w@1wt.eu>
Thu, 17 Feb 2022 16:45:58 +0000 (17:45 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 23 Feb 2022 16:11:33 +0000 (17:11 +0100)
commit34527d5354daeb9b63fc54eaab4c63baeebad3b0
tree71b884e199613b2c2546da1030ae863783a2c8c7
parent3ebe4d989cf2fdac8601e3dc0d3dd592e013c4ba
MEDIUM: init: split the early initialization in its own function

There are some delicate chicken-and-egg situations in the initialization
code, because the init() function currently does way too much (it goes
as far as parsing the config) and due to this it must be started very
late. But it's also in charge of initializing a number of variables that
are needed in early boot (e.g. hostname/pid for error reporting, or
entropy for random generators).

This patch carefully extracts all the early code that depends on
absolutely nothing, and places it immediately after the STG_LOCK init
stage. The only possible failures at this stage are only allocation
errors and they continue to provoke an immediate exit().

Some environment variables, hostname, date, pid etc are retrieved at
this stage. The program's arguments are also copied there since they're
needed to be kept intact for the master process.
src/haproxy.c