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