38 lines
1.7 KiB
Diff
38 lines
1.7 KiB
Diff
From 650352c713aeb3b47807c9699ceeb168f9f880b8 Mon Sep 17 00:00:00 2001
|
|
From: huangkaibin <huangkaibin@huawei.com>
|
|
Date: Tue, 13 Mar 2018 20:51:37 +0800
|
|
Subject: [PATCH] systemd-core: Do not finish job during daemon reloading in
|
|
unit_notify.
|
|
|
|
1. During daemon reload, a service unit will restore its state from dead to its deserialized state,
|
|
and unit_notify will be triggered to notify the state change.
|
|
Since JobRemove signal will not be sent during daemon-reload(see details of job_uninstall),
|
|
if one job is finished in unit_notify due to the deserialization of a service, the corresponding
|
|
job observers(such as systemctl) will not receive any JobRemove signals will hang forever.
|
|
2. The above problem will cause a systemctl command to hang forever by using the following steps to reproduce.
|
|
a) Ensuere a service(named A)is in running state.
|
|
b) execute "systemctl daemon-reload" and "systemctl start A" concurrently
|
|
c) the systemctl command will hang for it is in waiting for the JobRemoved signal, but not signals will come from systemd.
|
|
3. This patch fix this bug by not finishing job in unit_notify when it is in daemon reload.
|
|
---
|
|
src/core/unit.c | 3 ++-
|
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/core/unit.c b/src/core/unit.c
|
|
index 9e5f1a8..2da6f61 100644
|
|
--- a/src/core/unit.c
|
|
+++ b/src/core/unit.c
|
|
@@ -1831,7 +1831,8 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, UnitNotifyFlag
|
|
|
|
unit_update_on_console(u);
|
|
|
|
- if (u->job) {
|
|
+ if (u->job &&
|
|
+ !(m->n_reloading > 0 && u->job->state != JOB_RUNNING && os == UNIT_INACTIVE)) { /*do not finish job during daemon-reload*/
|
|
unexpected = false;
|
|
|
|
if (u->job->state == JOB_WAITING)
|
|
--
|
|
1.8.3.1
|
|
|