Skip to content

Commit

Permalink
Possibly handle journald restarts better.
Browse files Browse the repository at this point in the history
I've encountered two runaway tallow daemons now that seem to
coincide with journald restarts that send it spinning tight
on the `continue` statement and hitting the same _get_data()
error (ENOENT).

I'm unsure if the `break` will fix it, but the `continue`
is definitely broken here. Hopefully the `sd_journal_wait()`
will properly reassess the journal state and notify us of
rotations or other issues.
  • Loading branch information
ahkok committed Jun 25, 2018
1 parent 8655223 commit 5503ff0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.64])
AC_INIT([tallow], [10], [[email protected]])
AC_INIT([tallow], [11], [[email protected]])
AM_INIT_AUTOMAKE([foreign])
AC_CONFIG_FILES([Makefile])

Expand Down
5 changes: 4 additions & 1 deletion tallow.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,14 +434,17 @@ int main(void)
if (r == SD_JOURNAL_INVALIDATE) {
fprintf(stderr, "Journal was rotated, resetting\n");
sd_journal_seek_tail(j);
} else if (r == SD_JOURNAL_NOP) {
dbg("Timeout reached, waiting again\n");
continue;
}

while (sd_journal_next(j) != 0) {
char *m;

if (sd_journal_get_data(j, "MESSAGE", &d, &l) < 0) {
fprintf(stderr, "Failed to read message field: %s\n", strerror(-r));
continue;
break;
}

m = strndup(d, l+1);
Expand Down

0 comments on commit 5503ff0

Please sign in to comment.