From fc53809803cd2bc2434e312b19a18fa36776da12 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 05:50:40 +0200 Subject: Adding upstream version 256. Signed-off-by: Daniel Baumann --- src/shared/journal-file-util.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'src/shared/journal-file-util.c') 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); } -- cgit v1.2.3