diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2016-04-25 11:34:35 -0400 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2016-04-27 16:04:48 -0400 |
| commit | 651415bd617af87ee0addfc15d6985b6946600ed (patch) | |
| tree | 2a3f537c22a68dae1e554f8a4de5be1a1394a9d5 /lib/systemd.c | |
| parent | e2dd9485cb35cf81add815959927a3016116d898 (diff) | |
quagga: Fixup startup to allow consistency between sysV and systemd
We want the ability to start up quagga in a varied set of
environments. This needs to be done in SysV and systemd
startups. As such refactor the code to allow us to
allow end users to easily switch between the two
sysV:
edit the /etc/quagga/daemons file
service quagga [start|stop|reload|restart]
Systemd:
edit the /etc/quagga/daemons file
systemctl [start|stop|reload|restart] quagga
Ticket: CM-10634
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Diffstat (limited to 'lib/systemd.c')
| -rw-r--r-- | lib/systemd.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/lib/systemd.c b/lib/systemd.c index 5f5f5c3fff..4c78cf328c 100644 --- a/lib/systemd.c +++ b/lib/systemd.c @@ -46,10 +46,11 @@ systemd_send_information (const char *info) * A return of 0 means that we are not watchdoged */ static int -systemd_get_watchdog_time (void) +systemd_get_watchdog_time (int the_process) { #if defined HAVE_SYSTEMD uint64_t usec; + char *watchdog = NULL; int ret; ret = sd_watchdog_enabled (0, &usec); @@ -58,9 +59,28 @@ systemd_get_watchdog_time (void) * If return is 0 -> we don't want watchdog * if return is < 0, some sort of failure occurred */ - if (ret <= 0) + if (ret < 0) return 0; + /* + * systemd can return that this process + * is not the expected sender of the watchdog timer + * If we set the_process = 0 then we expect to + * be able to send the watchdog to systemd + * irrelevant of the pid of this process. + */ + if (ret == 0 && the_process) + return 0; + + if (ret == 0 && !the_process) + { + watchdog = getenv ("WATCHDOG_USEC"); + if (!watchdog) + return 0; + + usec = atol (watchdog); + } + return (usec / 1000000)/ 3; #else return 0; @@ -90,11 +110,11 @@ systemd_send_watchdog (struct thread *t) } void -systemd_send_started (struct thread_master *m) +systemd_send_started (struct thread_master *m, int the_process) { assert (m != NULL); - wsecs = systemd_get_watchdog_time(); + wsecs = systemd_get_watchdog_time(the_process); systemd_master = m; systemd_send_information ("READY=1"); |
