Skip to content

Commit 2a39b91

Browse files
committed
service: fix for RestartMode=direct option
With the fix done in PR28215, the unit restart job is created with type JOB_START. Because of that, it is not properly merged anymore with the old one: the merged job has state JOB_RUNNING. It should have state JOB_WAITING. I think that the old job is not cleaned up because we don't go through the failed state. With this fix, the merged job is properly created with state JOB_WAITING.
1 parent e568fea commit 2a39b91

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/core/job.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static void job_merge_into_installed(Job *j, Job *other) {
217217
j->ignore_order = j->ignore_order || other->ignore_order;
218218
}
219219

220-
Job* job_install(Job *j) {
220+
Job* job_install(Job *j, JobMode mode) {
221221
Job **pj;
222222
Job *uj;
223223

@@ -235,7 +235,7 @@ Job* job_install(Job *j) {
235235
/* not conflicting, i.e. mergeable */
236236

237237
if (uj->state == JOB_WAITING ||
238-
(job_type_allows_late_merge(j->type) && job_type_is_superset(uj->type, j->type))) {
238+
(job_type_allows_late_merge(j->type) && mode != JOB_RESTART_DEPENDENCIES && job_type_is_superset(uj->type, j->type))) {
239239
job_merge_into_installed(uj, j);
240240
log_unit_debug(uj->unit,
241241
"Merged %s/%s into installed job %s/%s as %"PRIu32,

src/core/job.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ Job* job_new(Unit *unit, JobType type);
169169
Job* job_new_raw(Unit *unit);
170170
void job_unlink(Job *job);
171171
Job* job_free(Job *job);
172-
Job* job_install(Job *j);
172+
Job* job_install(Job *j, JobMode mode);
173173
int job_install_deserialized(Job *j);
174174
void job_uninstall(Job *j);
175175
void job_dump(Job *j, FILE *f, const char *prefix);

src/core/transaction.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ static int transaction_apply(
657657
/* Clean the job dependencies */
658658
transaction_unlink_job(tr, j, false);
659659

660-
installed_job = job_install(j);
660+
installed_job = job_install(j, mode);
661661
if (installed_job != j) {
662662
/* j has been merged into a previously installed job */
663663
if (tr->anchor_job == j)

0 commit comments

Comments
 (0)