teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame SOURCES/0325-journal-forget-file-after-encountering-an-error.patch

84b277
From 1ff08dbb562d007bbca2323ab219324058fe8adb Mon Sep 17 00:00:00 2001
84b277
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
84b277
Date: Thu, 27 Feb 2014 00:11:54 -0500
84b277
Subject: [PATCH] journal: forget file after encountering an error
84b277
84b277
If we encounter an inconsistency in a file, let's just
84b277
ignore it. Otherwise, after previous patch, we would try,
84b277
and fail, to use this file in every invocation of sd_journal_next
84b277
or sd_journal_previous that happens afterwards.
84b277
84b277
(cherry-picked from a9a245c128af6c0418085062c60251bc51fa4a94)
84b277
84b277
Resolves: #1147524
84b277
---
84b277
 src/journal/sd-journal.c | 16 ++++++++++++----
84b277
 1 file changed, 12 insertions(+), 4 deletions(-)
84b277
84b277
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
84b277
index 67a77e6..8e3bb0c 100644
84b277
--- a/src/journal/sd-journal.c
84b277
+++ b/src/journal/sd-journal.c
84b277
@@ -50,6 +50,8 @@
84b277
 
84b277
 #define DEFAULT_DATA_THRESHOLD (64*1024)
84b277
 
84b277
+static void remove_file_real(sd_journal *j, JournalFile *f);
84b277
+
84b277
 static bool journal_pid_changed(sd_journal *j) {
84b277
         assert(j);
84b277
 
84b277
@@ -895,6 +897,7 @@ static int real_journal_next(sd_journal *j, direction_t direction) {
84b277
                 r = next_beyond_location(j, f, direction, &o, &p);
84b277
                 if (r < 0) {
84b277
                         log_debug("Can't iterate through %s, ignoring: %s", f->path, strerror(-r));
84b277
+                        remove_file_real(j, f);
84b277
                         continue;
84b277
                 } else if (r == 0)
84b277
                         continue;
84b277
@@ -1368,7 +1371,7 @@ static int add_file(sd_journal *j, const char *prefix, const char *filename) {
84b277
 }
84b277
 
84b277
 static int remove_file(sd_journal *j, const char *prefix, const char *filename) {
84b277
-        char *path;
84b277
+        _cleanup_free_ char *path;
84b277
         JournalFile *f;
84b277
 
84b277
         assert(j);
84b277
@@ -1380,10 +1383,17 @@ static int remove_file(sd_journal *j, const char *prefix, const char *filename)
84b277
                 return -ENOMEM;
84b277
 
84b277
         f = hashmap_get(j->files, path);
84b277
-        free(path);
84b277
         if (!f)
84b277
                 return 0;
84b277
 
84b277
+        remove_file_real(j, f);
84b277
+        return 0;
84b277
+}
84b277
+
84b277
+static void remove_file_real(sd_journal *j, JournalFile *f) {
84b277
+        assert(j);
84b277
+        assert(f);
84b277
+
84b277
         hashmap_remove(j->files, f->path);
84b277
 
84b277
         log_debug("File %s removed.", f->path);
84b277
@@ -1401,8 +1411,6 @@ static int remove_file(sd_journal *j, const char *prefix, const char *filename)
84b277
         journal_file_close(f);
84b277
 
84b277
         j->current_invalidate_counter ++;
84b277
-
84b277
-        return 0;
84b277
 }
84b277
 
84b277
 static int add_directory(sd_journal *j, const char *prefix, const char *dirname) {