summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-02-27 00:11:54 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-03-05 00:17:27 -0500
commita9a245c128af6c0418085062c60251bc51fa4a94 (patch)
tree5c613aff8ce15cbedb72a1edd8d2ea35d4bb11d9
parentfb099c8d2af6620db2709e826a258089d10cdfe8 (diff)
journal: forget file after encountering an error
If we encounter an inconsistency in a file, let's just ignore it. Otherwise, after previous patch, we would try, and fail, to use this file in every invocation of sd_journal_next or sd_journal_previous that happens afterwards.
-rw-r--r--src/journal/sd-journal.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index ef455e901d..b54bc21090 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -51,6 +51,8 @@
#define DEFAULT_DATA_THRESHOLD (64*1024)
+static void remove_file_real(sd_journal *j, JournalFile *f);
+
static bool journal_pid_changed(sd_journal *j) {
assert(j);
@@ -885,6 +887,7 @@ static int real_journal_next(sd_journal *j, direction_t direction) {
r = next_beyond_location(j, f, direction, &o, &p);
if (r < 0) {
log_debug("Can't iterate through %s, ignoring: %s", f->path, strerror(-r));
+ remove_file_real(j, f);
continue;
} else if (r == 0)
continue;
@@ -1339,7 +1342,7 @@ static int add_file(sd_journal *j, const char *prefix, const char *filename) {
}
static int remove_file(sd_journal *j, const char *prefix, const char *filename) {
- char *path;
+ _cleanup_free_ char *path;
JournalFile *f;
assert(j);
@@ -1351,10 +1354,17 @@ static int remove_file(sd_journal *j, const char *prefix, const char *filename)
return -ENOMEM;
f = hashmap_get(j->files, path);
- free(path);
if (!f)
return 0;
+ remove_file_real(j, f);
+ return 0;
+}
+
+static void remove_file_real(sd_journal *j, JournalFile *f) {
+ assert(j);
+ assert(f);
+
hashmap_remove(j->files, f->path);
log_debug("File %s removed.", f->path);
@@ -1372,8 +1382,6 @@ static int remove_file(sd_journal *j, const char *prefix, const char *filename)
journal_file_close(f);
j->current_invalidate_counter ++;
-
- return 0;
}
static int add_directory(sd_journal *j, const char *prefix, const char *dirname) {