ryantimwilson / rpms / systemd

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