diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:40 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:40 +0000 |
commit | fc53809803cd2bc2434e312b19a18fa36776da12 (patch) | |
tree | b4b43bd6538f51965ce32856e9c053d0f90919c8 /src/shared/journal-file-util.c | |
parent | Adding upstream version 255.5. (diff) | |
download | systemd-fc53809803cd2bc2434e312b19a18fa36776da12.tar.xz systemd-fc53809803cd2bc2434e312b19a18fa36776da12.zip |
Adding upstream version 256.upstream/256
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/shared/journal-file-util.c')
-rw-r--r-- | src/shared/journal-file-util.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/src/shared/journal-file-util.c b/src/shared/journal-file-util.c index bdceac4..8df165d 100644 --- a/src/shared/journal-file-util.c +++ b/src/shared/journal-file-util.c @@ -404,7 +404,7 @@ JournalFile* journal_file_offline_close(JournalFile *f) { if (sd_event_source_get_enabled(f->post_change_timer, NULL) > 0) journal_file_post_change(f); - sd_event_source_disable_unref(f->post_change_timer); + f->post_change_timer = sd_event_source_disable_unref(f->post_change_timer); journal_file_set_offline(f, true); @@ -451,7 +451,7 @@ int journal_file_rotate( set_clear_with_destructor(deferred_closes, journal_file_offline_close); r = journal_file_open( - /* fd= */ -1, + /* fd= */ -EBADF, path, (*f)->open_flags, file_flags, @@ -476,14 +476,13 @@ int journal_file_open_reliably( uint64_t compress_threshold_bytes, JournalMetrics *metrics, MMapCache *mmap_cache, - JournalFile *template, JournalFile **ret) { _cleanup_(journal_file_offline_closep) JournalFile *old_file = NULL; int r; r = journal_file_open( - /* fd= */ -1, + /* fd= */ -EBADF, fname, open_flags, file_flags, @@ -491,7 +490,7 @@ int journal_file_open_reliably( compress_threshold_bytes, metrics, mmap_cache, - template, + /* template = */ NULL, ret); if (!IN_SET(r, -EBADMSG, /* Corrupted */ @@ -517,23 +516,19 @@ int journal_file_open_reliably( /* The file is corrupted. Rotate it away and try it again (but only once) */ log_warning_errno(r, "File %s corrupted or uncleanly shut down, renaming and replacing.", fname); - if (!template) { - /* The file is corrupted and no template is specified. Try opening it read-only as the - * template before rotating to inherit its sequence number and ID. */ - r = journal_file_open(-1, fname, - (open_flags & ~(O_ACCMODE|O_CREAT|O_EXCL)) | O_RDONLY, - file_flags, 0, compress_threshold_bytes, NULL, - mmap_cache, NULL, &old_file); - if (r < 0) - log_debug_errno(r, "Failed to continue sequence from file %s, ignoring: %m", fname); - else - template = old_file; - } + /* The file is corrupted. Try opening it read-only as the template before rotating to inherit its + * sequence number and ID. */ + r = journal_file_open(-EBADF, fname, + (open_flags & ~(O_ACCMODE|O_CREAT|O_EXCL)) | O_RDONLY, + file_flags, 0, compress_threshold_bytes, NULL, + mmap_cache, /* template = */ NULL, &old_file); + if (r < 0) + log_debug_errno(r, "Failed to continue sequence from file %s, ignoring: %m", fname); r = journal_file_dispose(AT_FDCWD, fname); if (r < 0) return r; - return journal_file_open(-1, fname, open_flags, file_flags, mode, compress_threshold_bytes, metrics, - mmap_cache, template, ret); + return journal_file_open(-EBADF, fname, open_flags, file_flags, mode, compress_threshold_bytes, metrics, + mmap_cache, /* template = */ old_file, ret); } |