pid1: touch the /run/systemd/show-status just once

We know if we created the file before, no need to repeat the operation. The
state in /run should always match our internal state. Since we call
manager_set_show_status() quite often internally, this saves quite a few
pointless syscalls.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-02-29 11:30:16 +01:00
parent 7365a29670
commit ef15d3e1ab
1 changed files with 8 additions and 6 deletions

View File

@ -4083,12 +4083,14 @@ void manager_set_show_status(Manager *m, ShowStatus mode, const char *reason) {
if (!MANAGER_IS_SYSTEM(m))
return;
bool enabled = show_status_on(mode);
if (mode != m->show_status)
log_debug("%s (%s) showing of status (%s).",
enabled ? "Enabling" : "Disabling",
strna(show_status_to_string(mode)),
reason);
if (mode == m->show_status)
return;
bool enabled = IN_SET(mode, SHOW_STATUS_TEMPORARY, SHOW_STATUS_YES);
log_debug("%s (%s) showing of status (%s).",
enabled ? "Enabling" : "Disabling",
strna(show_status_to_string(mode)),
reason);
m->show_status = mode;
if (enabled)