odhcpd: simplify signal handling
Currently, odhcpd's main() function will:
- call uloop_init()
- set up some signal handlers for SIGUSR1/SIGINT/SIGTERM
(SIGUSR1 is ignored, the other handlers call uloop_end())
- call odhcpd_run(), which will:
- set up some signal handlers for SIGTERM/SIGINT/SIGHUP
(the first two call uloop_end(), SIGHUP calls odhcpd_reload())
Note that uloop_init() will call uloop_setup_signals() which will call
uloop_setup_signals() which will install handlers for SIGINT/SIGTERM
which will set uloop_cancelled to true (e.g. the same thing that
uloop_end() does).
In other words, the signal handlers are modified three times, and since
the default "exit" action is to call uloop_end(), there's nothing that
will actually react to signals until uloop_run() is called, meaning that
the startup will be uninterruptible if e.g. ubus_init() fails since
it'll just retry in a loop with no handling of signals.
So, simplify and fix this by letting uloop handle the signals and
checking if uloop has been told to exit, removing a bunch of
special-purpose code.
Signed-off-by: David Härdeman <[email protected]>
Link: https://github.com/openwrt/odhcpd/pull/312
Signed-off-by: Álvaro Fernández Rojas <[email protected]>