From ef15d3e1ab67549a65b41e853e4d3b3b08a350d9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sat, 29 Feb 2020 11:30:16 +0100 Subject: [PATCH] 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. --- src/core/manager.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/core/manager.c b/src/core/manager.c index feb7b3efd0..c1bb365850 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) -- 2.25.1