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