summaryrefslogtreecommitdiff
path: root/src/journal-remote/journal-upload-journal.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-04-05 20:27:48 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-04-05 20:28:56 -0400
commit0aa176a751a00b5645007c4d0763078ce2824aba (patch)
treefbbc4d02b55d1aaa1bdbcff821c00c8e5a8f012b /src/journal-remote/journal-upload-journal.c
parentd79ca7a622abbb0df6f5166cc0e4669373d9a614 (diff)
journal-upload: make watchdog state non-static
Also parse watchdog config when creating the Uploader object.
Diffstat (limited to 'src/journal-remote/journal-upload-journal.c')
-rw-r--r--src/journal-remote/journal-upload-journal.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/journal-remote/journal-upload-journal.c b/src/journal-remote/journal-upload-journal.c
index ac6eb58a9f..8ce8e1895e 100644
--- a/src/journal-remote/journal-upload-journal.c
+++ b/src/journal-remote/journal-upload-journal.c
@@ -244,24 +244,18 @@ static ssize_t write_entry(char *buf, size_t size, Uploader *u) {
}
static inline void check_update_watchdog(Uploader *u) {
- usec_t watchdog_usec;
- static usec_t before;
usec_t after;
usec_t elapsed_time;
- if (sd_watchdog_enabled(false, &watchdog_usec) < 0)
+ if (u->watchdog_usec <= 0)
return;
- if (u->reset_reference_timestamp) {
- before = now(CLOCK_MONOTONIC);
- u->reset_reference_timestamp = false;
- } else {
- after = now(CLOCK_MONOTONIC);
- elapsed_time = usec_sub(after, before);
- if (elapsed_time > watchdog_usec / 2) {
- log_debug("Update watchdog timer");
- sd_notify(false, "WATCHDOG=1");
- u->reset_reference_timestamp = true;
- }
+
+ after = now(CLOCK_MONOTONIC);
+ elapsed_time = usec_sub(after, u->watchdog_timestamp);
+ if (elapsed_time > u->watchdog_usec / 2) {
+ log_debug("Update watchdog timer");
+ sd_notify(false, "WATCHDOG=1");
+ u->watchdog_timestamp = after;
}
}