|
|
4cad4c |
From 4a1405998671caaaad5b24d4cef309c05175b1c1 Mon Sep 17 00:00:00 2001
|
|
|
4cad4c |
From: ypf791 <ypf791@gmail.com>
|
|
|
4cad4c |
Date: Fri, 19 Jul 2019 18:28:04 +0800
|
|
|
4cad4c |
Subject: [PATCH] core: coldplug possible nop_job
|
|
|
4cad4c |
|
|
|
4cad4c |
When a unit in a state INACTIVE or DEACTIVATING, JobType JOB_TRY_RESTART or
|
|
|
4cad4c |
JOB_TRY_RELOAD will be collapsed to JOB_NOP. And use u->nop_job instead
|
|
|
4cad4c |
of u->job.
|
|
|
4cad4c |
|
|
|
4cad4c |
If a JOB_NOP job is going on with a waiting state, a parallel daemon-reload
|
|
|
4cad4c |
just install it during deserialization. Without a coldplug, the job will
|
|
|
4cad4c |
not be in m->run_queue, which results in a hung try-restart or
|
|
|
4cad4c |
try-reload process.
|
|
|
4cad4c |
|
|
|
4cad4c |
Reproduce:
|
|
|
4cad4c |
|
|
|
4cad4c |
run systemctl try-restart test.servcie (inactive) repeatly in a terminal.
|
|
|
4cad4c |
run systemctl daemon-reload repeatly in other terminals.
|
|
|
4cad4c |
|
|
|
4cad4c |
After successful reproduce, systemctl list-jobs will list the hang job.
|
|
|
4cad4c |
|
|
|
4cad4c |
Upsteam:
|
|
|
4cad4c |
systemd/systemd#13124
|
|
|
4cad4c |
|
|
|
4cad4c |
(cherry picked from commit b49e14d5f3081dfcd363d8199a14c0924ae9152f)
|
|
|
4cad4c |
|
|
|
4cad4c |
Resolves: #1829798
|
|
|
4cad4c |
---
|
|
|
4cad4c |
src/core/unit.c | 6 ++++--
|
|
|
4cad4c |
1 file changed, 4 insertions(+), 2 deletions(-)
|
|
|
4cad4c |
|
|
|
4cad4c |
diff --git a/src/core/unit.c b/src/core/unit.c
|
|
|
4cad4c |
index 61799bf9e3..f57260727f 100644
|
|
|
4cad4c |
--- a/src/core/unit.c
|
|
|
4cad4c |
+++ b/src/core/unit.c
|
|
|
4cad4c |
@@ -3696,6 +3696,7 @@ int unit_add_node_dependency(Unit *u, const char *what, bool wants, UnitDependen
|
|
|
4cad4c |
int unit_coldplug(Unit *u) {
|
|
|
4cad4c |
int r = 0, q;
|
|
|
4cad4c |
char **i;
|
|
|
4cad4c |
+ Job *uj;
|
|
|
4cad4c |
|
|
|
4cad4c |
assert(u);
|
|
|
4cad4c |
|
|
|
4cad4c |
@@ -3718,8 +3719,9 @@ int unit_coldplug(Unit *u) {
|
|
|
4cad4c |
r = q;
|
|
|
4cad4c |
}
|
|
|
4cad4c |
|
|
|
4cad4c |
- if (u->job) {
|
|
|
4cad4c |
- q = job_coldplug(u->job);
|
|
|
4cad4c |
+ uj = u->job ?: u->nop_job;
|
|
|
4cad4c |
+ if (uj) {
|
|
|
4cad4c |
+ q = job_coldplug(uj);
|
|
|
4cad4c |
if (q < 0 && r >= 0)
|
|
|
4cad4c |
r = q;
|
|
|
4cad4c |
}
|