chiark / gitweb /
transaction: do not add installed jobs to the transaction
[elogind.git] / src / core / transaction.c
index 8fa89a7be3981d7831ed638ec3647a5000a308eb..c00dd452eb1249f3c6d24dbb131faa9ca815147a 100644 (file)
@@ -760,13 +760,9 @@ static Job* transaction_add_one_job(Transaction *tr, JobType type, Unit *unit, b
                 }
         }
 
-        if (unit->job && unit->job->type == type)
-                j = unit->job;
-        else {
-                j = job_new(unit->manager, type, unit);
-                if (!j)
-                        return NULL;
-        }
+        j = job_new(unit, type);
+        if (!j)
+                return NULL;
 
         j->generation = 0;
         j->marker = NULL;
@@ -789,6 +785,12 @@ static Job* transaction_add_one_job(Transaction *tr, JobType type, Unit *unit, b
         return j;
 }
 
+static void transaction_job_dependency_free(Transaction *tr, JobDependency *l) {
+        if (!l->subject)
+                LIST_REMOVE(JobDependency, subject, tr->anchor, l);
+        job_dependency_free(l);
+}
+
 static void transaction_unlink_job(Transaction *tr, Job *j, bool delete_dependencies) {
         assert(tr);
         assert(j);
@@ -806,12 +808,12 @@ static void transaction_unlink_job(Transaction *tr, Job *j, bool delete_dependen
         j->transaction_prev = j->transaction_next = NULL;
 
         while (j->subject_list)
-                job_dependency_free(j->subject_list, tr);
+                transaction_job_dependency_free(tr, j->subject_list);
 
         while (j->object_list) {
                 Job *other = j->object_list->matters ? j->object_list->subject : NULL;
 
-                job_dependency_free(j->object_list, tr);
+                transaction_job_dependency_free(tr, j->object_list);
 
                 if (other && delete_dependencies) {
                         log_debug("Deleting job %s/%s as dependency of job %s/%s",
@@ -835,6 +837,7 @@ int transaction_add_job_and_dependencies(
                 DBusError *e,
                 Job **_ret) {
         Job *ret;
+        JobDependency *l;
         Iterator i;
         Unit *dep;
         int r;
@@ -884,9 +887,14 @@ int transaction_add_job_and_dependencies(
         ret->ignore_order = ret->ignore_order || ignore_order;
 
         /* Then, add a link to the job. */
-        if (!job_dependency_new(by, ret, matters, conflicts, tr))
+        l = job_dependency_new(by, ret, matters, conflicts);
+        if (!l)
                 return -ENOMEM;
 
+        /* If the link has no subject job, it's the anchor link. */
+        if (!by)
+                LIST_PREPEND(JobDependency, subject, tr->anchor, l);
+
         if (is_new && !ignore_requirements) {
                 Set *following;