]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/core/transaction.c
tree-wide: drop _pure_ + _const_ from local, static functions
[thirdparty/systemd.git] / src / core / transaction.c
index c85bc667ceba48b72dd4e38290175583d97f0f03..85f673f447ddc3c6c3cf7f5e2accf768ec2b9783 100644 (file)
@@ -123,7 +123,7 @@ static void transaction_merge_and_delete_job(Transaction *tr, Job *j, Job *other
         transaction_delete_job(tr, other, true);
 }
 
-_pure_ static bool job_is_conflicted_by(Job *j) {
+static bool job_is_conflicted_by(Job *j) {
         assert(j);
 
         /* Returns true if this job is pulled in by a least one
@@ -308,7 +308,7 @@ static void transaction_drop_redundant(Transaction *tr) {
         } while (again);
 }
 
-_pure_ static bool job_matters_to_anchor(Job *job) {
+static bool job_matters_to_anchor(Job *job) {
         assert(job);
         assert(!job->transaction_prev);
 
@@ -657,14 +657,19 @@ static int transaction_apply(
                 /* Clean the job dependencies */
                 transaction_unlink_job(tr, j, false);
 
-                installed_job = job_install(j);
+                /* When RestartMode=direct is used, the service being restarted don't enter the inactive/failed
+                 * state, i.e. unit_process_job -> job_finish_and_invalidate is never called, and the previous
+                 * job might still be running (especially for Type=oneshot services). We need to refuse
+                 * late merge and re-enqueue the anchor job. */
+                installed_job = job_install(j,
+                                            /* refuse_late_merge = */ mode == JOB_RESTART_DEPENDENCIES && j == tr->anchor_job);
                 if (installed_job != j) {
                         /* j has been merged into a previously installed job */
                         if (tr->anchor_job == j)
                                 tr->anchor_job = installed_job;
+
                         hashmap_remove_value(m->jobs, UINT32_TO_PTR(j->id), j);
-                        job_free(j);
-                        j = installed_job;
+                        free_and_replace_full(j, installed_job, job_free);
                 }
 
                 job_add_to_run_queue(j);