a19bc6
From ca55fb67bc81313edf0aa6523b6f9ffce50ecdda Mon Sep 17 00:00:00 2001
a19bc6
From: Michal Sekletar <msekletar@users.noreply.github.com>
a19bc6
Date: Mon, 24 Apr 2017 18:33:12 +0200
a19bc6
Subject: [PATCH] sd-journal: return SD_JOURNAL_INVALIDATE only if journal
a19bc6
 files were actually deleted/moved (#5580)
a19bc6
a19bc6
When caller invokes sd_journal_open() we usually open at least one
a19bc6
directory with journal files. add_root_directory() function increments
a19bc6
current_invalidate_counter. After sd_journal_open() returns
a19bc6
current_invalidate_counter != last_invalidate_counter.
a19bc6
a19bc6
After caller waits for journal events (e.g. waits for new messages in
a19bc6
journal) then it usually calls sd_journal_process(). However, on first
a19bc6
call to sd_journal_process(), function determine_change() returns
a19bc6
SD_JOURNAL_INVALIDATE even though no journal files were
a19bc6
deleted/moved. This is because current_invalidate_counter !=
a19bc6
last_invalidate_counter.
a19bc6
a19bc6
After the fix we make sure counters has the same value before we begin
a19bc6
processing inotify events.
a19bc6
a19bc6
(cherry picked from commit f934644424daa6c86fd2284fe8f33ea233ece874)
a19bc6
a19bc6
Resolves: #1446140
a19bc6
---
a19bc6
 src/journal/sd-journal.c | 1 +
a19bc6
 1 file changed, 1 insertion(+)
a19bc6
a19bc6
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
181b3f
index 20456c3a1..72f312b67 100644
a19bc6
--- a/src/journal/sd-journal.c
a19bc6
+++ b/src/journal/sd-journal.c
a19bc6
@@ -2190,6 +2190,7 @@ _public_ int sd_journal_process(sd_journal *j) {
a19bc6
         assert_return(!journal_pid_changed(j), -ECHILD);
a19bc6
 
a19bc6
         j->last_process_usec = now(CLOCK_MONOTONIC);
a19bc6
+        j->last_invalidate_counter = j->current_invalidate_counter;
a19bc6
 
a19bc6
         for (;;) {
a19bc6
                 union inotify_event_buffer buffer;