From: Lennart Poettering Date: Fri, 9 Feb 2018 21:38:46 +0000 (+0100) Subject: sd-journal: make sure it's safe to call sd_journal_process() before the first sd_jour... X-Git-Tag: v238~108^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=10c4d6405f74258ea4fac5db4888c1bf49ad5399;p=thirdparty%2Fsystemd.git sd-journal: make sure it's safe to call sd_journal_process() before the first sd_journal_wait() In that case we have no inotify fd yet, and there's nothing to process hence. Let's make the call a NOP. (Previously, without this change we'd end up trying to read off inotify fd -1, which is quite a problem... 😢) --- diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index 221c51e1997..4deee461c3f 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -2540,6 +2540,9 @@ _public_ int sd_journal_process(sd_journal *j) { assert_return(j, -EINVAL); assert_return(!journal_pid_changed(j), -ECHILD); + if (j->inotify_fd < 0) /* We have no inotify fd yet? Then there's noting to process. */ + return 0; + j->last_process_usec = now(CLOCK_MONOTONIC); j->last_invalidate_counter = j->current_invalidate_counter;