Merge pull request #12679 from yuwata/journal-issue-12400

journal: do not trigger assertion when journal_file_close() get NULL
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-05-28 14:20:34 +02:00 committed by GitHub
commit b7437f1c55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 11 deletions

View file

@ -340,7 +340,8 @@ bool journal_file_is_offlining(JournalFile *f) {
}
JournalFile* journal_file_close(JournalFile *f) {
assert(f);
if (!f)
return NULL;
#if HAVE_GCRYPT
/* Write the final tag */

View file

@ -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,

View file

@ -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);
@ -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;
}
@ -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);