diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2020-11-29 01:28:08 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-02-16 23:09:41 +0100 |
commit | bb1296b55a222cbab24d533006e730529009258c (patch) | |
tree | 88f657b5d1a0738ffc69d81541e31d39de6aa554 /src/libsystemd | |
parent | Merge pull request #18601 from keszybz/env-assign-cleanup (diff) | |
download | systemd-bb1296b55a222cbab24d533006e730529009258c.tar.xz systemd-bb1296b55a222cbab24d533006e730529009258c.zip |
journal-file: fix archiving offline journals
The existing set_offline() short-circuit erroneously included
when f->archive was true and header->state was STATE_OFFLINE.
This commit makes the short-circuit f->archive aware, so it will
only catch scenarios where there's not an offlining in progress
and the header state matches the target state of either archived
or offline.
Fixes https://github.com/systemd/systemd/issues/17770
Diffstat (limited to 'src/libsystemd')
-rw-r--r-- | src/libsystemd/sd-journal/journal-file.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c index cfa4657f84..2545f1314b 100644 --- a/src/libsystemd/sd-journal/journal-file.c +++ b/src/libsystemd/sd-journal/journal-file.c @@ -208,6 +208,7 @@ static bool journal_file_set_offline_try_restart(JournalFile *f) { * context without involving another thread. */ int journal_file_set_offline(JournalFile *f, bool wait) { + int target_state; bool restarted; int r; @@ -219,9 +220,13 @@ int journal_file_set_offline(JournalFile *f, bool wait) { if (f->fd < 0 || !f->header) return -EINVAL; + target_state = f->archive ? STATE_ARCHIVED : STATE_OFFLINE; + /* An offlining journal is implicitly online and may modify f->header->state, - * we must also join any potentially lingering offline thread when not online. */ - if (!journal_file_is_offlining(f) && f->header->state != STATE_ONLINE) + * we must also join any potentially lingering offline thread when already in + * the desired offline state. + */ + if (!journal_file_is_offlining(f) && f->header->state == target_state) return journal_file_set_offline_thread_join(f); /* Restart an in-flight offline thread and wait if needed, or join a lingering done one. */ |