mirror of
https://github.com/systemd/systemd.git
synced 2025-01-26 14:04:03 +03:00
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.
This commit is contained in:
parent
fb099c8d2a
commit
a9a245c128
Notes:
Zbigniew Jędrzejewski-Szmek
2014-03-05 00:18:26 -05:00
Backport: bugfix
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user