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