core/manager: still send out STATUS=Ready for user manager

This effectively reverts 37d15cd132.

The offending commit wrongly assumed that the second READY=1
notification is for system scope only, but it also serves the purpose
of flushing out previous STATUS= containing user unit job status.
This commit is contained in:
Mike Yuan 2024-10-10 21:16:05 +02:00 committed by Daan De Meyer
parent 225ddc4a72
commit da81a10865

View File

@ -3885,7 +3885,7 @@ static void manager_notify_finished(Manager *m) {
log_taint_string(m);
}
static void manager_send_ready_user_scope(Manager *m) {
static void manager_send_ready_on_basic_target(Manager *m) {
int r;
assert(m);
@ -3904,18 +3904,18 @@ static void manager_send_ready_user_scope(Manager *m) {
m->status_ready = false;
}
static void manager_send_ready_system_scope(Manager *m) {
static void manager_send_ready_on_idle(Manager *m) {
int r;
assert(m);
if (!MANAGER_IS_SYSTEM(m))
return;
/* Skip the notification if nothing changed. */
if (m->ready_sent && m->status_ready)
return;
/* Note that for user managers, we might have already sent READY=1 in manager_send_ready_user_scope().
* But we still need to flush STATUS=. The second READY=1 will be treated as a noop so it doesn't
* hurt to send it twice. */
r = sd_notify(/* unset_environment= */ false,
"READY=1\n"
"STATUS=Ready.");
@ -3940,7 +3940,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_user_scope(m);
manager_send_ready_on_basic_target(m);
/* Log the taint string as soon as we reach basic.target */
log_taint_string(m);
@ -3971,7 +3971,7 @@ 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_system_scope(m);
manager_send_ready_on_idle(m);
/* Notify Type=idle units that we are done now */
manager_close_idle_pipe(m);