From: Zbigniew Jędrzejewski-Szmek Date: Sat, 29 Feb 2020 10:30:16 +0000 (+0100) Subject: pid1: touch the /run/systemd/show-status just once X-Git-Tag: v245-rc2~15^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ef15d3e1ab67549a65b41e853e4d3b3b08a350d9;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/core/manager.c b/src/core/manager.c index feb7b3efd07..c1bb3658508 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -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)