summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-07-05 12:25:23 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-07-19 11:36:25 +0200
commit6d9326595592f98e8126eacb4176acd8c3516d5c (patch)
tree98f6a9f7d447563708a0857ab1f8dd5df3360953 /src
parentmanager: always log when starting a "special unit" (diff)
downloadsystemd-6d9326595592f98e8126eacb4176acd8c3516d5c.tar.xz
systemd-6d9326595592f98e8126eacb4176acd8c3516d5c.zip
manager: rework sending of STATUS=
We would send READY=1,STATUS="Startup finished in …" once after finishing boot. This changes the message to just "Ready.". The time used to reach readiness is not part of the ongoing status — it's just a bit of debug information that it useful in some scenarious, but completely uninteresting most of the time. Also, when we start sending status about other things in subsequent patches, we can't really go back to showing "Startup finished in …" later on. So let's just show "Ready." whenever we're in the steady state. In manager_check_finished(), more steps are skipped if MANAGER_IS_FINISHED(). Those steps are idempotent, but no need to waste cycles trying to do them more than once. We'll now also check whether to send the status message whenever the job queue runs empty. If we already sent the exact same message already, we'll not send again.
Diffstat (limited to 'src')
-rw-r--r--src/core/manager.c34
-rw-r--r--src/core/manager.h3
2 files changed, 23 insertions, 14 deletions
diff --git a/src/core/manager.c b/src/core/manager.c
index e269e87021..efa0efcb0c 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -3440,28 +3440,32 @@ static void manager_notify_finished(Manager *m) {
bus_manager_send_finished(m, firmware_usec, loader_usec, kernel_usec, initrd_usec, userspace_usec, total_usec);
- sd_notifyf(false,
- m->ready_sent ? "STATUS=Startup finished in %s."
- : "READY=1\n"
- "STATUS=Startup finished in %s.",
- FORMAT_TIMESPAN(total_usec, USEC_PER_MSEC));
- m->ready_sent = true;
-
log_taint_string(m);
}
-static void manager_send_ready(Manager *m) {
+static void user_manager_send_ready(Manager *m) {
assert(m);
/* We send READY=1 on reaching basic.target only when running in --user mode. */
if (!MANAGER_IS_USER(m) || m->ready_sent)
return;
- m->ready_sent = true;
-
sd_notifyf(false,
"READY=1\n"
"STATUS=Reached " SPECIAL_BASIC_TARGET ".");
+ m->ready_sent = true;
+ m->status_ready = false;
+}
+
+static void manager_send_ready(Manager *m) {
+ if (m->ready_sent && m->status_ready)
+ /* Skip the notification if nothing changed. */
+ return;
+
+ sd_notifyf(false,
+ "%sSTATUS=Ready.",
+ m->ready_sent ? "READY=1\n" : "");
+ m->ready_sent = m->status_ready = true;
}
static void manager_check_basic_target(Manager *m) {
@@ -3478,7 +3482,7 @@ static void manager_check_basic_target(Manager *m) {
return;
/* For user managers, send out READY=1 as soon as we reach basic.target */
- manager_send_ready(m);
+ user_manager_send_ready(m);
/* Log the taint string as soon as we reach basic.target */
log_taint_string(m);
@@ -3509,6 +3513,11 @@ void manager_check_finished(Manager *m) {
if (hashmap_buckets(m->jobs) > hashmap_size(m->units) / 10)
m->jobs = hashmap_free(m->jobs);
+ manager_send_ready(m);
+
+ if (MANAGER_IS_FINISHED(m))
+ return;
+
manager_flip_auto_status(m, false, "boot finished");
/* Notify Type=idle units that we are done now */
@@ -3523,9 +3532,6 @@ void manager_check_finished(Manager *m) {
/* This is no longer the first boot */
manager_set_first_boot(m, false);
- if (MANAGER_IS_FINISHED(m))
- return;
-
dual_timestamp_get(m->timestamps + MANAGER_TIMESTAMP_FINISH);
manager_notify_finished(m);
diff --git a/src/core/manager.h b/src/core/manager.h
index 6b1ed48beb..284ea42a9d 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -329,6 +329,9 @@ struct Manager {
/* Have we already sent out the READY=1 notification? */
bool ready_sent;
+ /* Was the last status sent "STATUS=Ready."? */
+ bool status_ready;
+
/* Have we already printed the taint line if necessary? */
bool taint_logged;