Skip to content

Commit 8ee6529

Browse files
chenglin130Jan Synacek
authored and
Jan Synacek
committed
core: coldplug possible nop_job
When a unit in a state INACTIVE or DEACTIVATING, JobType JOB_TRY_RESTART or JOB_TRY_RELOAD will be collapsed to JOB_NOP. And use u->nop_job instead of u->job. If a JOB_NOP job is going on with a waiting state, a parallel daemon-reload just install it during deserialization. Without a coldplug, the job will not be in m->run_queue, which results in a hung try-restart or try-reload process. Reproduce: 1. run systemctl try-restart test.servcie (inactive) repeatly in a terminal. 2. run systemctl daemon-reload repeatly in other terminals. After successful reproduce, systemctl list-jobs will list the hang job. Upsteam: systemd/systemd#13124 Resolves: #1829754
1 parent ba36c6a commit 8ee6529

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/core/unit.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -2918,15 +2918,17 @@ static int unit_add_deserialized_job_coldplug(Unit *u) {
29182918

29192919
int unit_coldplug(Unit *u, Hashmap *deferred_work) {
29202920
int r;
2921+
Job *uj;
29212922

29222923
assert(u);
29232924

29242925
if (UNIT_VTABLE(u)->coldplug)
29252926
if ((r = UNIT_VTABLE(u)->coldplug(u, deferred_work)) < 0)
29262927
return r;
29272928

2928-
if (u->job) {
2929-
r = job_coldplug(u->job);
2929+
uj = u->job ?: u->nop_job;
2930+
if (uj) {
2931+
r = job_coldplug(uj);
29302932
if (r < 0)
29312933
return r;
29322934
} else if (u->deserialized_job >= 0)

0 commit comments

Comments
 (0)