Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

journal: do not trigger assertion when journal_file_close() get NULL #12679

Merged
merged 2 commits into from May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/journal/journal-file.c
Expand Up @@ -340,7 +340,8 @@ bool journal_file_is_offlining(JournalFile *f) {
}

JournalFile* journal_file_close(JournalFile *f) {
assert(f);
if (!f)
return NULL;
keszybz marked this conversation as resolved.
Show resolved Hide resolved

#if HAVE_GCRYPT
/* Write the final tag */
Expand Down
1 change: 1 addition & 0 deletions src/journal/journal-file.h
Expand Up @@ -145,6 +145,7 @@ int journal_file_open(
int journal_file_set_offline(JournalFile *f, bool wait);
bool journal_file_is_offlining(JournalFile *f);
JournalFile* journal_file_close(JournalFile *j);
DEFINE_TRIVIAL_CLEANUP_FUNC(JournalFile*, journal_file_close);

int journal_file_open_reliably(
const char *fname,
Expand Down
15 changes: 5 additions & 10 deletions src/journal/journald-server.c
Expand Up @@ -255,7 +255,7 @@ static int open_journal(
JournalMetrics *metrics,
JournalFile **ret) {

JournalFile *f;
_cleanup_(journal_file_closep) JournalFile *f = NULL;
int r;

assert(s);
Expand All @@ -273,12 +273,10 @@ static int open_journal(
return r;

r = journal_file_enable_post_change_timer(f, s->event, POST_CHANGE_TIMER_INTERVAL_USEC);
if (r < 0) {
(void) journal_file_close(f);
if (r < 0)
return r;
}

*ret = f;
*ret = TAKE_PTR(f);
return r;
}

Expand Down Expand Up @@ -2232,11 +2230,8 @@ void server_done(Server *s) {

client_context_flush_all(s);

if (s->system_journal)
(void) journal_file_close(s->system_journal);

if (s->runtime_journal)
(void) journal_file_close(s->runtime_journal);
(void) journal_file_close(s->system_journal);
(void) journal_file_close(s->runtime_journal);

ordered_hashmap_free_with_destructor(s->user_journals, journal_file_close);

Expand Down