1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-18 06:03:42 +03:00

homed: don't wait indefinitely for workers on exit

Let's put some time-limit on it.

Fixes: #22901
(cherry picked from commit f8f621821a30b5b7e6c69dfb770e1c4cbc3db715)
(cherry picked from commit 202a79e7c506df0606bd17d1c7522bacc776398d)
This commit is contained in:
Lennart Poettering 2022-09-05 15:14:11 +02:00 committed by Zbigniew Jędrzejewski-Szmek
parent 559e851a95
commit 7c2a025984

View File

@ -3143,13 +3143,21 @@ int home_set_current_message(Home *h, sd_bus_message *m) {
}
int home_wait_for_worker(Home *h) {
int r;
assert(h);
if (h->worker_pid <= 0)
return 0;
log_info("Worker process for home %s is still running while exiting. Waiting for it to finish.", h->user_name);
(void) wait_for_terminate(h->worker_pid, NULL);
r = wait_for_terminate_with_timeout(h->worker_pid, 30 * USEC_PER_SEC);
if (r == -ETIMEDOUT)
log_warning_errno(r, "Waiting for worker process for home %s timed out. Ignoring.", h->user_name);
else
log_warning_errno(r, "Failed to wait for worker process for home %s. Ignoring.", h->user_name);
(void) hashmap_remove_value(h->manager->homes_by_worker_pid, PID_TO_PTR(h->worker_pid), h);
h->worker_pid = 0;
return 1;