Skip to content

Commit

Permalink
core: in --user mode, report READY=1 as soon as basic.target is reached
Browse files Browse the repository at this point in the history
When a user logs in, systemd-pam will wait for the user manager instance to
report readiness. We don't need to wait for all the jobs to finish, it
is enough if the basic startup is done and the user manager is responsive.

systemd --user will now send out a READY=1 notification when either of two
conditions becomes true:
- basic.target/start job is gone,
- the initial transaction is done.

Also fixes systemd#2863.
  • Loading branch information
keszybz committed Oct 18, 2017
1 parent a524f12 commit 2f15bc8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 0 additions & 2 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,6 @@ Features:

* introduce systemd-timesync-wait.service or so to sync on an NTP fix?

* systemd --user should issue sd_notify() upon reaching basic.target, not on becoming idle

* consider showing the unit names during boot up in the status output, not just the unit descriptions

* maybe allow timer units with an empty Units= setting, so that they
Expand Down
19 changes: 17 additions & 2 deletions src/core/manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -3062,9 +3062,11 @@ 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,
"READY=1\n"
"STATUS=Startup finished in %s.",
m->ready_sent ? "STATUS=Startup finished in %s."
: "READY=1\n"
"STATUS=Startup finished in %s.",
format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC));
m->ready_sent = true;
}

void manager_check_finished(Manager *m) {
Expand All @@ -3079,6 +3081,19 @@ void manager_check_finished(Manager *m) {
if (m->exit_code != MANAGER_OK)
return;

/* For user managers, send out READY=1 as soon as we reach basic.target */
if (MANAGER_IS_USER(m) && !m->ready_sent) {
Unit *u;

u = manager_get_unit(m, SPECIAL_BASIC_TARGET);
if (u && !u->job) {
sd_notifyf(false,
"READY=1\n"
"STATUS=Reached " SPECIAL_BASIC_TARGET ".");
m->ready_sent = true;
}
}

if (hashmap_size(m->jobs) > 0) {
if (m->jobs_in_progress_event_source)
/* Ignore any failure, this is only for feedback */
Expand Down
2 changes: 2 additions & 0 deletions src/core/manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ struct Manager {

bool taint_usr:1;

bool ready_sent:1;

unsigned test_run_flags:8;

/* If non-zero, exit with the following value when the systemd
Expand Down

0 comments on commit 2f15bc8

Please sign in to comment.