daandemeyer / rpms / systemd

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