From 651415bd617af87ee0addfc15d6985b6946600ed Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 25 Apr 2016 11:34:35 -0400 Subject: 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 Reviewed-by: Daniel Walton --- lib/systemd.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'lib/systemd.c') 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"); -- cgit v1.2.3