Merge pull request #34707 from YHNdnzj/user-manager-reexec
core: fix STATUS=Ready for user manager; units/user@.service: issue daemon-reexec when notify-reloading
This commit is contained in:
@@ -92,7 +92,6 @@ int manager_serialize(
|
||||
(void) serialize_item_format(f, "current-job-id", "%" PRIu32, m->current_job_id);
|
||||
(void) serialize_item_format(f, "n-installed-jobs", "%u", m->n_installed_jobs);
|
||||
(void) serialize_item_format(f, "n-failed-jobs", "%u", m->n_failed_jobs);
|
||||
(void) serialize_bool(f, "ready-sent", m->ready_sent);
|
||||
(void) serialize_bool(f, "taint-logged", m->taint_logged);
|
||||
(void) serialize_bool(f, "service-watchdogs", m->service_watchdogs);
|
||||
|
||||
@@ -356,15 +355,6 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
|
||||
else
|
||||
m->n_failed_jobs += n;
|
||||
|
||||
} else if ((val = startswith(l, "ready-sent="))) {
|
||||
int b;
|
||||
|
||||
b = parse_boolean(val);
|
||||
if (b < 0)
|
||||
log_notice("Failed to parse ready-sent flag '%s', ignoring.", val);
|
||||
else
|
||||
m->ready_sent = m->ready_sent || b;
|
||||
|
||||
} else if ((val = startswith(l, "taint-logged="))) {
|
||||
int b;
|
||||
|
||||
@@ -558,7 +548,7 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
|
||||
|
||||
if (q < _MANAGER_TIMESTAMP_MAX) /* found it */
|
||||
(void) deserialize_dual_timestamp(val, m->timestamps + q);
|
||||
else if (!STARTSWITH_SET(l, "kdbus-fd=", "honor-device-enumeration=")) /* ignore deprecated values */
|
||||
else if (!STARTSWITH_SET(l, "kdbus-fd=", "honor-device-enumeration=", "ready-sent=")) /* ignore deprecated values */
|
||||
log_notice("Unknown serialization item '%s', ignoring.", l);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -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);
|
||||
|
||||
@@ -107,25 +107,13 @@ case "$command" in
|
||||
|
||||
[ -d /run/systemd/system ] || exit 0
|
||||
|
||||
users=$(systemctl list-units 'user@*' --legend=no | sed -n -r 's/.*user@([0-9]+).service.*/\1/p')
|
||||
|
||||
if [[ "$command" =~ reexec ]]; then
|
||||
for user in $users; do
|
||||
SYSTEMD_BUS_TIMEOUT={{UPDATE_HELPER_USER_TIMEOUT_SEC}}s \
|
||||
systemctl --user -M "$user@" daemon-reexec &
|
||||
done
|
||||
wait
|
||||
fi
|
||||
|
||||
if [[ "$command" =~ reload ]]; then
|
||||
for user in $users; do
|
||||
SYSTEMD_BUS_TIMEOUT={{UPDATE_HELPER_USER_TIMEOUT_SEC}}s \
|
||||
systemctl --user -M "$user@" daemon-reload &
|
||||
done
|
||||
wait
|
||||
if [[ "$command" =~ reexec|reload ]]; then
|
||||
SYSTEMD_BUS_TIMEOUT={{UPDATE_HELPER_USER_TIMEOUT_SEC}}s systemctl reload "user@*.service"
|
||||
fi
|
||||
|
||||
if [[ "$command" =~ restart ]]; then
|
||||
users=$(systemctl list-units 'user@*' --legend=no | sed -n -r 's/.*user@([0-9]+).service.*/\1/p')
|
||||
|
||||
for user in $users; do
|
||||
SYSTEMD_BUS_TIMEOUT={{UPDATE_HELPER_USER_TIMEOUT_SEC}}s \
|
||||
systemctl --user -M "$user@" reload-or-restart --marked &
|
||||
|
||||
@@ -23,6 +23,10 @@ StateDirectory=capsules/%i
|
||||
RuntimeDirectory=capsules/%i
|
||||
LogExtraFields=CAPSULE=%i
|
||||
Slice=capsule.slice
|
||||
# Reexecute the manager on service reload, instead of reloading.
|
||||
# This provides a synchronous method for restarting all user manager
|
||||
# instances after upgrade.
|
||||
ReloadSignal=RTMIN+25
|
||||
KillMode=mixed
|
||||
Delegate=pids memory cpu
|
||||
DelegateSubgroup=init.scope
|
||||
|
||||
@@ -20,6 +20,10 @@ PAMName=systemd-user
|
||||
Type=notify-reload
|
||||
ExecStart={{LIBEXECDIR}}/systemd --user
|
||||
Slice=user-%i.slice
|
||||
# Reexecute the manager on service reload, instead of reloading.
|
||||
# This provides a synchronous method for restarting all user manager
|
||||
# instances after upgrade.
|
||||
ReloadSignal=RTMIN+25
|
||||
KillMode=mixed
|
||||
Delegate=pids memory cpu
|
||||
DelegateSubgroup=init.scope
|
||||
|
||||
Reference in New Issue
Block a user