]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
service: fix for RestartMode=direct option 27584/head
authorRichard Phibel <rphibel@googlemail.com>
Thu, 6 Jul 2023 12:03:35 +0000 (14:03 +0200)
committerRichard Phibel <rphibel@googlemail.com>
Thu, 6 Jul 2023 12:35:33 +0000 (14:35 +0200)
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.

src/core/job.c
src/core/job.h
src/core/transaction.c

index 3d5e4e42d126ae064d865ee79c0be28f53eb54a3..95e71c48e23e6fb4150c4e61978978a820815d2b 100644 (file)
@@ -217,7 +217,7 @@ static void job_merge_into_installed(Job *j, Job *other) {
         j->ignore_order = j->ignore_order || other->ignore_order;
 }
 
-Job* job_install(Job *j) {
+Job* job_install(Job *j, JobMode mode) {
         Job **pj;
         Job *uj;
 
@@ -235,7 +235,7 @@ Job* job_install(Job *j) {
                         /* not conflicting, i.e. mergeable */
 
                         if (uj->state == JOB_WAITING ||
-                            (job_type_allows_late_merge(j->type) && job_type_is_superset(uj->type, j->type))) {
+                            (job_type_allows_late_merge(j->type) && mode != JOB_RESTART_DEPENDENCIES && job_type_is_superset(uj->type, j->type))) {
                                 job_merge_into_installed(uj, j);
                                 log_unit_debug(uj->unit,
                                                "Merged %s/%s into installed job %s/%s as %"PRIu32,
index d3b98d98b6111435d17383e091633c794289d929..2c4fbdf4eda0a2c1c967cbbe99d8f29def70806c 100644 (file)
@@ -169,7 +169,7 @@ Job* job_new(Unit *unit, JobType type);
 Job* job_new_raw(Unit *unit);
 void job_unlink(Job *job);
 Job* job_free(Job *job);
-Job* job_install(Job *j);
+Job* job_install(Job *j, JobMode mode);
 int job_install_deserialized(Job *j);
 void job_uninstall(Job *j);
 void job_dump(Job *j, FILE *f, const char *prefix);
index c85bc667ceba48b72dd4e38290175583d97f0f03..8b8e02f1c77d9426f3dd73b7687a688aea92627e 100644 (file)
@@ -657,7 +657,7 @@ static int transaction_apply(
                 /* Clean the job dependencies */
                 transaction_unlink_job(tr, j, false);
 
-                installed_job = job_install(j);
+                installed_job = job_install(j, mode);
                 if (installed_job != j) {
                         /* j has been merged into a previously installed job */
                         if (tr->anchor_job == j)