diff options
| author | whitespace / reindent <invalid@invalid.invalid> | 2017-07-17 14:03:14 +0200 |
|---|---|---|
| committer | whitespace / reindent <invalid@invalid.invalid> | 2017-07-17 14:04:07 +0200 |
| commit | d62a17aedeb0eebdba98238874bb13d62c48dbf9 (patch) | |
| tree | 3b319b1d61c8b85b4d1f06adf8b844bb8a9b5107 /lib/systemd.c | |
| parent | 888ac268a0077fc9ebd1218cec6ae472af0bfc40 (diff) | |
*: reindentreindent-master-after
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/systemd.c')
| -rw-r--r-- | lib/systemd.c | 107 |
1 files changed, 51 insertions, 56 deletions
diff --git a/lib/systemd.c b/lib/systemd.c index 341de9eabe..8a2a5eeac3 100644 --- a/lib/systemd.c +++ b/lib/systemd.c @@ -32,65 +32,61 @@ * Wrapper this silliness if we * don't have systemd */ -void -systemd_send_information (const char *info) +void systemd_send_information(const char *info) { #if defined HAVE_SYSTEMD - sd_notify (0, info); + sd_notify(0, info); #else - return; + return; #endif } /* * A return of 0 means that we are not watchdoged */ -static int -systemd_get_watchdog_time (int the_process) +static int 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); - - /* - * If return is 0 -> we don't want watchdog - * if return is < 0, some sort of failure occurred - */ - 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; + uint64_t usec; + char *watchdog = NULL; + int ret; + + ret = sd_watchdog_enabled(0, &usec); + + /* + * If return is 0 -> we don't want watchdog + * if return is < 0, some sort of failure occurred + */ + 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; + return 0; #endif } -void -systemd_send_stopping (void) +void systemd_send_stopping(void) { - systemd_send_information ("STOPPING=1"); + systemd_send_information("STOPPING=1"); } /* @@ -99,25 +95,24 @@ systemd_send_stopping (void) int wsecs = 0; struct thread_master *systemd_master = NULL; -static int -systemd_send_watchdog (struct thread *t) +static int systemd_send_watchdog(struct thread *t) { - systemd_send_information ("WATCHDOG=1"); + systemd_send_information("WATCHDOG=1"); - thread_add_timer(systemd_master, systemd_send_watchdog, NULL, wsecs, NULL); + thread_add_timer(systemd_master, systemd_send_watchdog, NULL, wsecs, + NULL); - return 1; + return 1; } -void -systemd_send_started (struct thread_master *m, int the_process) +void systemd_send_started(struct thread_master *m, int the_process) { - assert (m != NULL); + assert(m != NULL); - wsecs = systemd_get_watchdog_time(the_process); - systemd_master = m; + wsecs = systemd_get_watchdog_time(the_process); + systemd_master = m; - systemd_send_information ("READY=1"); - if (wsecs != 0) - thread_add_timer(m, systemd_send_watchdog, m, wsecs, NULL); + systemd_send_information("READY=1"); + if (wsecs != 0) + thread_add_timer(m, systemd_send_watchdog, m, wsecs, NULL); } |
