dcavalca / rpms / systemd

Forked from rpms/systemd 4 months ago
Clone
52b84b
From 0f7ee0007b8267cc66b638a44da6ddd984ece412 Mon Sep 17 00:00:00 2001
be3800
From: =?UTF-8?q?Michal=20Sekleta=CC=81r?= <msekleta@redhat.com>
be3800
Date: Fri, 27 Mar 2020 17:01:59 +0100
be3800
Subject: [PATCH] sd-journal: remove the dead code and actually fix #14695
be3800
be3800
journal_file_fstat() returns an error if we call it on already unlinked
be3800
journal file and hence we never reach remove_file_real() which is the
be3800
entire point.
be3800
be3800
I must have made some mistake while testing the fix that got me thinking
be3800
the issue is gone while opposite was true.
be3800
be3800
Fixes #14695
be3800
be3800
(cherry picked from commit 8581b9f9732d4c158bb5f773230a65ce77f2c292)
be3800
52b84b
Resolves: #1796128
be3800
---
be3800
 src/journal/sd-journal.c | 7 +++----
be3800
 1 file changed, 3 insertions(+), 4 deletions(-)
be3800
be3800
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
be3800
index c06255e273..4c502978de 100644
be3800
--- a/src/journal/sd-journal.c
be3800
+++ b/src/journal/sd-journal.c
be3800
@@ -2597,13 +2597,12 @@ _public_ int sd_journal_wait(sd_journal *j, uint64_t timeout_usec) {
be3800
                    Get rid of the deleted files now so they don't stay around indefinitely. */
be3800
                 ORDERED_HASHMAP_FOREACH(f, j->files, i) {
be3800
                         r = journal_file_fstat(f);
be3800
-                        if (r < 0) {
be3800
+                        if (r == -EIDRM)
be3800
+                                remove_file_real(j, f);
be3800
+                        else if (r < 0) {
be3800
                                 log_debug_errno(r,"Failed to fstat() journal file '%s' : %m", f->path);
be3800
                                 continue;
be3800
                         }
be3800
-
be3800
-                        if (f->last_stat.st_nlink <= 0)
be3800
-                                remove_file_real(j, f);
be3800
                 }
be3800
 
be3800
                 /* The journal might have changed since the context