]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pid1: touch the /run/systemd/show-status just once
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 29 Feb 2020 10:30:16 +0000 (11:30 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 1 Mar 2020 10:42:26 +0000 (11:42 +0100)
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

index feb7b3efd07a01dee27cb5567206e4014ae0be4a..c1bb3658508e0e403144d38d4ae4e1f872712020 100644 (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)