summaryrefslogtreecommitdiff
path: root/src/core/manager.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-01-27 22:27:07 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-01-27 23:17:03 -0500
commitd450b6f2a9dd8a7fb14e9f8f771ddd70de7afc5e (patch)
treed44a69835242d48ad8b2dd2e947a31df3da708cd /src/core/manager.c
parent65b3903ff576488eaabb51d3c4fbf9c73d867d7c (diff)
manager: add systemd.show_status=auto mode
When set to auto, status will shown when the first ephemeral message is shown (a job has been running for five seconds). Then until the boot or shutdown ends, status messages will be shown. No indication about the switch is done: I think it should be clear for the user that first the cylon eye and the ephemeral messages appear, and afterwards messages are displayed. The initial arming of the event source was still wrong, but now should really be fixed.
Diffstat (limited to 'src/core/manager.c')
-rw-r--r--src/core/manager.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/core/manager.c b/src/core/manager.c
index 9ed802398b..9f615e64eb 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -102,7 +102,7 @@ static int manager_watch_jobs_in_progress(Manager *m) {
if (m->jobs_in_progress_event_source)
return 0;
- return sd_event_add_monotonic(m->event, JOBS_IN_PROGRESS_WAIT_USEC, 0, manager_dispatch_jobs_in_progress, m, &m->jobs_in_progress_event_source);
+ return sd_event_add_monotonic(m->event, now(CLOCK_MONOTONIC) + JOBS_IN_PROGRESS_WAIT_USEC, 0, manager_dispatch_jobs_in_progress, m, &m->jobs_in_progress_event_source);
}
#define CYLON_BUFFER_EXTRA (2*(sizeof(ANSI_RED_ON)-1) + sizeof(ANSI_HIGHLIGHT_RED_ON)-1 + 2*(sizeof(ANSI_HIGHLIGHT_OFF)-1))
@@ -148,6 +148,9 @@ static void manager_print_jobs_in_progress(Manager *m) {
assert(m);
+ if (m->show_status == SHOW_STATUS_AUTO)
+ manager_set_show_status(m, SHOW_STATUS_TEMPORARY);
+
print_nr = (m->jobs_in_progress_iteration / JOBS_IN_PROGRESS_PERIOD_DIVISOR) % m->n_running_jobs;
HASHMAP_FOREACH(j, m->jobs, i)
@@ -1637,12 +1640,12 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
case 20:
log_debug("Enabling showing of status.");
- manager_set_show_status(m, true);
+ manager_set_show_status(m, SHOW_STATUS_YES);
break;
case 21:
log_debug("Disabling showing of status.");
- manager_set_show_status(m, false);
+ manager_set_show_status(m, SHOW_STATUS_NO);
break;
case 22:
@@ -2456,6 +2459,9 @@ void manager_check_finished(Manager *m) {
return;
}
+ if (m->show_status == SHOW_STATUS_TEMPORARY)
+ manager_set_show_status(m, SHOW_STATUS_AUTO);
+
/* Notify Type=idle units that we are done now */
m->idle_pipe_event_source = sd_event_source_unref(m->idle_pipe_event_source);
manager_close_idle_pipe(m);
@@ -2754,15 +2760,16 @@ void manager_recheck_journal(Manager *m) {
log_open();
}
-void manager_set_show_status(Manager *m, bool b) {
+void manager_set_show_status(Manager *m, ShowStatus mode) {
assert(m);
+ assert(IN_SET(mode, SHOW_STATUS_AUTO, SHOW_STATUS_NO, SHOW_STATUS_YES, SHOW_STATUS_TEMPORARY));
if (m->running_as != SYSTEMD_SYSTEM)
return;
- m->show_status = b;
+ m->show_status = mode;
- if (b)
+ if (mode > 0)
touch("/run/systemd/show-status");
else
unlink("/run/systemd/show-status");
@@ -2777,7 +2784,7 @@ static bool manager_get_show_status(Manager *m) {
if (m->no_console_output)
return false;
- if (m->show_status)
+ if (m->show_status > 0)
return true;
/* If Plymouth is running make sure we show the status, so