mirror of
https://github.com/systemd/systemd.git
synced 2024-11-23 10:13:34 +08:00
journald: always unset flushed flag when the runtime journal is opened
If the runtime journal is opened, we will anyway write journal entries to the runtime journal, even if the persistent journal is writable. Hence, we need to flush the runtime journal file later.
This commit is contained in:
parent
349fa06134
commit
3148edb254
@ -335,6 +335,20 @@ static bool server_flushed_flag_is_set(Server *s) {
|
||||
return access(fn, F_OK) >= 0;
|
||||
}
|
||||
|
||||
static void server_drop_flushed_flag(Server *s) {
|
||||
const char *fn;
|
||||
|
||||
assert(s);
|
||||
|
||||
if (s->namespace)
|
||||
return;
|
||||
|
||||
fn = strjoina(s->runtime_directory, "/flushed");
|
||||
if (unlink(fn) < 0 && errno != ENOENT)
|
||||
log_ratelimit_warning_errno(errno, JOURNAL_LOG_RATELIMIT,
|
||||
"Failed to unlink %s, ignoring: %m", fn);
|
||||
}
|
||||
|
||||
static int server_system_journal_open(
|
||||
Server *s,
|
||||
bool flush_requested,
|
||||
@ -437,6 +451,7 @@ static int server_system_journal_open(
|
||||
server_add_acls(s->runtime_journal, 0);
|
||||
(void) cache_space_refresh(s, &s->runtime_storage);
|
||||
patch_min_use(&s->runtime_storage);
|
||||
server_drop_flushed_flag(s);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1450,7 +1465,6 @@ finish:
|
||||
}
|
||||
|
||||
static int server_relinquish_var(Server *s) {
|
||||
const char *fn;
|
||||
assert(s);
|
||||
|
||||
if (s->storage == STORAGE_NONE)
|
||||
@ -1470,11 +1484,6 @@ static int server_relinquish_var(Server *s) {
|
||||
ordered_hashmap_clear_with_destructor(s->user_journals, journal_file_offline_close);
|
||||
set_clear_with_destructor(s->deferred_closes, journal_file_offline_close);
|
||||
|
||||
fn = strjoina(s->runtime_directory, "/flushed");
|
||||
if (unlink(fn) < 0 && errno != ENOENT)
|
||||
log_ratelimit_warning_errno(errno, JOURNAL_LOG_RATELIMIT,
|
||||
"Failed to unlink %s, ignoring: %m", fn);
|
||||
|
||||
server_refresh_idle_timer(s);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user