1 #include "transaction.h"
2 #include "bus-errors.h"
4 static void transaction_unlink_job(Transaction *tr, Job *j, bool delete_dependencies);
6 static void transaction_delete_job(Transaction *tr, Job *j, bool delete_dependencies) {
10 /* Deletes one job from the transaction */
12 transaction_unlink_job(tr, j, delete_dependencies);
18 static void transaction_delete_unit(Transaction *tr, Unit *u) {
21 /* Deletes all jobs associated with a certain unit from the
24 while ((j = hashmap_get(tr->jobs, u)))
25 transaction_delete_job(tr, j, true);
28 void transaction_abort(Transaction *tr) {
33 while ((j = hashmap_first(tr->jobs)))
34 transaction_delete_job(tr, j, true);
36 assert(hashmap_isempty(tr->jobs));
39 static void transaction_find_jobs_that_matter_to_anchor(Job *j, unsigned generation) {
42 /* A recursive sweep through the graph that marks all units
43 * that matter to the anchor job, i.e. are directly or
44 * indirectly a dependency of the anchor job via paths that
45 * are fully marked as mattering. */
47 j->matters_to_anchor = true;
48 j->generation = generation;
50 LIST_FOREACH(subject, l, j->subject_list) {
52 /* This link does not matter */
56 /* This unit has already been marked */
57 if (l->object->generation == generation)
60 transaction_find_jobs_that_matter_to_anchor(l->object, generation);
64 static void transaction_merge_and_delete_job(Transaction *tr, Job *j, Job *other, JobType t) {
65 JobDependency *l, *last;
69 assert(j->unit == other->unit);
70 assert(!j->installed);
72 /* Merges 'other' into 'j' and then deletes 'other'. */
75 j->state = JOB_WAITING;
76 j->override = j->override || other->override;
78 j->matters_to_anchor = j->matters_to_anchor || other->matters_to_anchor;
80 /* Patch us in as new owner of the JobDependency objects */
82 LIST_FOREACH(subject, l, other->subject_list) {
83 assert(l->subject == other);
88 /* Merge both lists */
90 last->subject_next = j->subject_list;
92 j->subject_list->subject_prev = last;
93 j->subject_list = other->subject_list;
96 /* Patch us in as new owner of the JobDependency objects */
98 LIST_FOREACH(object, l, other->object_list) {
99 assert(l->object == other);
104 /* Merge both lists */
106 last->object_next = j->object_list;
108 j->object_list->object_prev = last;
109 j->object_list = other->object_list;
112 /* Kill the other job */
113 other->subject_list = NULL;
114 other->object_list = NULL;
115 transaction_delete_job(tr, other, true);
118 static bool job_is_conflicted_by(Job *j) {
123 /* Returns true if this job is pulled in by a least one
124 * ConflictedBy dependency. */
126 LIST_FOREACH(object, l, j->object_list)
133 static int delete_one_unmergeable_job(Transaction *tr, Job *j) {
138 /* Tries to delete one item in the linked list
139 * j->transaction_next->transaction_next->... that conflicts
140 * with another one, in an attempt to make an inconsistent
141 * transaction work. */
143 /* We rely here on the fact that if a merged with b does not
144 * merge with c, either a or b merge with c neither */
145 LIST_FOREACH(transaction, j, j)
146 LIST_FOREACH(transaction, k, j->transaction_next) {
149 /* Is this one mergeable? Then skip it */
150 if (job_type_is_mergeable(j->type, k->type))
153 /* Ok, we found two that conflict, let's see if we can
154 * drop one of them */
155 if (!j->matters_to_anchor && !k->matters_to_anchor) {
157 /* Both jobs don't matter, so let's
158 * find the one that is smarter to
159 * remove. Let's think positive and
160 * rather remove stops then starts --
161 * except if something is being
162 * stopped because it is conflicted by
163 * another unit in which case we
164 * rather remove the start. */
166 log_debug("Looking at job %s/%s conflicted_by=%s", j->unit->id, job_type_to_string(j->type), yes_no(j->type == JOB_STOP && job_is_conflicted_by(j)));
167 log_debug("Looking at job %s/%s conflicted_by=%s", k->unit->id, job_type_to_string(k->type), yes_no(k->type == JOB_STOP && job_is_conflicted_by(k)));
169 if (j->type == JOB_STOP) {
171 if (job_is_conflicted_by(j))
176 } else if (k->type == JOB_STOP) {
178 if (job_is_conflicted_by(k))
185 } else if (!j->matters_to_anchor)
187 else if (!k->matters_to_anchor)
192 /* Ok, we can drop one, so let's do so. */
193 log_debug("Fixing conflicting jobs by deleting job %s/%s", d->unit->id, job_type_to_string(d->type));
194 transaction_delete_job(tr, d, true);
201 static int transaction_merge_jobs(Transaction *tr, DBusError *e) {
208 /* First step, check whether any of the jobs for one specific
209 * task conflict. If so, try to drop one of them. */
210 HASHMAP_FOREACH(j, tr->jobs, i) {
215 LIST_FOREACH(transaction, k, j->transaction_next) {
216 if (job_type_merge(&t, k->type) >= 0)
219 /* OK, we could not merge all jobs for this
220 * action. Let's see if we can get rid of one
223 r = delete_one_unmergeable_job(tr, j);
225 /* Ok, we managed to drop one, now
226 * let's ask our callers to call us
227 * again after garbage collecting */
230 /* We couldn't merge anything. Failure */
231 dbus_set_error(e, BUS_ERROR_TRANSACTION_JOBS_CONFLICTING, "Transaction contains conflicting jobs '%s' and '%s' for %s. Probably contradicting requirement dependencies configured.",
232 job_type_to_string(t), job_type_to_string(k->type), k->unit->id);
237 /* Second step, merge the jobs. */
238 HASHMAP_FOREACH(j, tr->jobs, i) {
242 /* Merge all transactions */
243 LIST_FOREACH(transaction, k, j->transaction_next)
244 assert_se(job_type_merge(&t, k->type) == 0);
246 /* If an active job is mergeable, merge it too */
248 job_type_merge(&t, j->unit->job->type); /* Might fail. Which is OK */
250 while ((k = j->transaction_next)) {
252 transaction_merge_and_delete_job(tr, k, j, t);
255 transaction_merge_and_delete_job(tr, j, k, t);
258 if (j->unit->job && !j->installed)
259 transaction_merge_and_delete_job(tr, j, j->unit->job, t);
261 assert(!j->transaction_next);
262 assert(!j->transaction_prev);
268 static void transaction_drop_redundant(Transaction *tr) {
273 /* Goes through the transaction and removes all jobs that are
282 HASHMAP_FOREACH(j, tr->jobs, i) {
283 bool changes_something = false;
286 LIST_FOREACH(transaction, k, j) {
288 if (tr->anchor_job != k &&
289 (k->installed || job_type_is_redundant(k->type, unit_active_state(k->unit))) &&
290 (!k->unit->job || !job_type_is_conflicting(k->type, k->unit->job->type)))
293 changes_something = true;
297 if (changes_something)
300 /* log_debug("Found redundant job %s/%s, dropping.", j->unit->id, job_type_to_string(j->type)); */
301 transaction_delete_job(tr, j, false);
309 static bool unit_matters_to_anchor(Unit *u, Job *j) {
311 assert(!j->transaction_prev);
313 /* Checks whether at least one of the jobs for this unit
314 * matters to the anchor. */
316 LIST_FOREACH(transaction, j, j)
317 if (j->matters_to_anchor)
323 static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsigned generation, DBusError *e) {
330 assert(!j->transaction_prev);
332 /* Does a recursive sweep through the ordering graph, looking
333 * for a cycle. If we find cycle we try to break it. */
335 /* Have we seen this before? */
336 if (j->generation == generation) {
339 /* If the marker is NULL we have been here already and
340 * decided the job was loop-free from here. Hence
341 * shortcut things and return right-away. */
345 /* So, the marker is not NULL and we already have been
346 * here. We have a cycle. Let's try to break it. We go
347 * backwards in our path and try to find a suitable
348 * job to remove. We use the marker to find our way
349 * back, since smart how we are we stored our way back
351 log_warning("Found ordering cycle on %s/%s", j->unit->id, job_type_to_string(j->type));
354 for (k = from; k; k = ((k->generation == generation && k->marker != k) ? k->marker : NULL)) {
356 log_info("Walked on cycle path to %s/%s", k->unit->id, job_type_to_string(k->type));
360 !unit_matters_to_anchor(k->unit, k)) {
361 /* Ok, we can drop this one, so let's
366 /* Check if this in fact was the beginning of
374 log_warning("Breaking ordering cycle by deleting job %s/%s", delete->unit->id, job_type_to_string(delete->type));
375 transaction_delete_unit(tr, delete->unit);
379 log_error("Unable to break cycle");
381 dbus_set_error(e, BUS_ERROR_TRANSACTION_ORDER_IS_CYCLIC, "Transaction order is cyclic. See system logs for details.");
385 /* Make the marker point to where we come from, so that we can
386 * find our way backwards if we want to break a cycle. We use
387 * a special marker for the beginning: we point to
389 j->marker = from ? from : j;
390 j->generation = generation;
392 /* We assume that the the dependencies are bidirectional, and
393 * hence can ignore UNIT_AFTER */
394 SET_FOREACH(u, j->unit->dependencies[UNIT_BEFORE], i) {
397 /* Is there a job for this unit? */
398 o = hashmap_get(tr->jobs, u);
400 /* Ok, there is no job for this in the
401 * transaction, but maybe there is already one
408 r = transaction_verify_order_one(tr, o, j, generation, e);
413 /* Ok, let's backtrack, and remember that this entry is not on
414 * our path anymore. */
420 static int transaction_verify_order(Transaction *tr, unsigned *generation, DBusError *e) {
429 /* Check if the ordering graph is cyclic. If it is, try to fix
430 * that up by dropping one of the jobs. */
434 HASHMAP_FOREACH(j, tr->jobs, i)
435 if ((r = transaction_verify_order_one(tr, j, NULL, g, e)) < 0)
441 static void transaction_collect_garbage(Transaction *tr) {
446 /* Drop jobs that are not required by any other job */
454 HASHMAP_FOREACH(j, tr->jobs, i) {
455 if (tr->anchor_job == j || j->object_list) {
456 /* log_debug("Keeping job %s/%s because of %s/%s", */
457 /* j->unit->id, job_type_to_string(j->type), */
458 /* j->object_list->subject ? j->object_list->subject->unit->id : "root", */
459 /* j->object_list->subject ? job_type_to_string(j->object_list->subject->type) : "root"); */
463 /* log_debug("Garbage collecting job %s/%s", j->unit->id, job_type_to_string(j->type)); */
464 transaction_delete_job(tr, j, true);
472 static int transaction_is_destructive(Transaction *tr, DBusError *e) {
478 /* Checks whether applying this transaction means that
479 * existing jobs would be replaced */
481 HASHMAP_FOREACH(j, tr->jobs, i) {
484 assert(!j->transaction_prev);
485 assert(!j->transaction_next);
489 !job_type_is_superset(j->type, j->unit->job->type)) {
491 dbus_set_error(e, BUS_ERROR_TRANSACTION_IS_DESTRUCTIVE, "Transaction is destructive.");
499 static void transaction_minimize_impact(Transaction *tr) {
503 /* Drops all unnecessary jobs that reverse already active jobs
504 * or that stop a running service. */
512 HASHMAP_FOREACH(j, tr->jobs, i) {
513 LIST_FOREACH(transaction, j, j) {
514 bool stops_running_service, changes_existing_job;
516 /* If it matters, we shouldn't drop it */
517 if (j->matters_to_anchor)
520 /* Would this stop a running service?
521 * Would this change an existing job?
522 * If so, let's drop this entry */
524 stops_running_service =
525 j->type == JOB_STOP && UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(j->unit));
527 changes_existing_job =
529 job_type_is_conflicting(j->type, j->unit->job->type);
531 if (!stops_running_service && !changes_existing_job)
534 if (stops_running_service)
535 log_debug("%s/%s would stop a running service.", j->unit->id, job_type_to_string(j->type));
537 if (changes_existing_job)
538 log_debug("%s/%s would change existing job.", j->unit->id, job_type_to_string(j->type));
540 /* Ok, let's get rid of this */
541 log_debug("Deleting %s/%s to minimize impact.", j->unit->id, job_type_to_string(j->type));
543 transaction_delete_job(tr, j, true);
555 static int transaction_apply(Transaction *tr, Manager *m, JobMode mode) {
560 /* Moves the transaction jobs to the set of active jobs */
562 if (mode == JOB_ISOLATE) {
564 /* When isolating first kill all installed jobs which
565 * aren't part of the new transaction */
567 HASHMAP_FOREACH(j, m->jobs, i) {
568 assert(j->installed);
570 if (hashmap_get(tr->jobs, j->unit))
573 /* 'j' itself is safe to remove, but if other jobs
574 are invalidated recursively, our iterator may become
575 invalid and we need to start over. */
576 if (job_finish_and_invalidate(j, JOB_CANCELED) > 0)
581 HASHMAP_FOREACH(j, tr->jobs, i) {
583 assert(!j->transaction_prev);
584 assert(!j->transaction_next);
589 r = hashmap_put(m->jobs, UINT32_TO_PTR(j->id), j);
594 while ((j = hashmap_steal_first(tr->jobs))) {
597 /* log_debug("Skipping already installed job %s/%s as %u", j->unit->id, job_type_to_string(j->type), (unsigned) j->id); */
609 m->n_installed_jobs ++;
611 /* We're fully installed. Now let's free data we don't
614 /* Clean the job dependencies */
615 transaction_unlink_job(tr, j, false);
617 job_add_to_run_queue(j);
618 job_add_to_dbus_queue(j);
621 log_debug("Installed new job %s/%s as %u", j->unit->id, job_type_to_string(j->type), (unsigned) j->id);
628 HASHMAP_FOREACH(j, tr->jobs, i) {
632 hashmap_remove(m->jobs, UINT32_TO_PTR(j->id));
638 int transaction_activate(Transaction *tr, Manager *m, JobMode mode, DBusError *e) {
640 unsigned generation = 1;
644 /* This applies the changes recorded in tr->jobs to
645 * the actual list of jobs, if possible. */
647 /* First step: figure out which jobs matter */
648 transaction_find_jobs_that_matter_to_anchor(tr->anchor_job, generation++);
650 /* Second step: Try not to stop any running services if
651 * we don't have to. Don't try to reverse running
652 * jobs if we don't have to. */
653 if (mode == JOB_FAIL)
654 transaction_minimize_impact(tr);
656 /* Third step: Drop redundant jobs */
657 transaction_drop_redundant(tr);
660 /* Fourth step: Let's remove unneeded jobs that might
662 if (mode != JOB_ISOLATE)
663 transaction_collect_garbage(tr);
665 /* Fifth step: verify order makes sense and correct
666 * cycles if necessary and possible */
667 r = transaction_verify_order(tr, &generation, e);
672 log_warning("Requested transaction contains an unfixable cyclic ordering dependency: %s", bus_error(e, r));
676 /* Let's see if the resulting transaction ordering
677 * graph is still cyclic... */
681 /* Sixth step: let's drop unmergeable entries if
682 * necessary and possible, merge entries we can
684 r = transaction_merge_jobs(tr, e);
689 log_warning("Requested transaction contains unmergeable jobs: %s", bus_error(e, r));
693 /* Seventh step: an entry got dropped, let's garbage
694 * collect its dependencies. */
695 if (mode != JOB_ISOLATE)
696 transaction_collect_garbage(tr);
698 /* Let's see if the resulting transaction still has
699 * unmergeable entries ... */
702 /* Eights step: Drop redundant jobs again, if the merging now allows us to drop more. */
703 transaction_drop_redundant(tr);
705 /* Ninth step: check whether we can actually apply this */
706 if (mode == JOB_FAIL) {
707 r = transaction_is_destructive(tr, e);
709 log_notice("Requested transaction contradicts existing jobs: %s", bus_error(e, r));
714 /* Tenth step: apply changes */
715 r = transaction_apply(tr, m, mode);
717 log_warning("Failed to apply transaction: %s", strerror(-r));
721 assert(hashmap_isempty(tr->jobs));
726 static Job* transaction_add_one_job(Transaction *tr, JobType type, Unit *unit, bool override, bool *is_new) {
732 /* Looks for an existing prospective job and returns that. If
733 * it doesn't exist it is created and added to the prospective
736 f = hashmap_get(tr->jobs, unit);
738 LIST_FOREACH(transaction, j, f) {
739 assert(j->unit == unit);
741 if (j->type == type) {
748 j = job_new(unit, type);
754 j->matters_to_anchor = false;
755 j->override = override;
757 LIST_PREPEND(Job, transaction, f, j);
759 if (hashmap_replace(tr->jobs, unit, f) < 0) {
760 LIST_REMOVE(Job, transaction, f, j);
768 /* log_debug("Added job %s/%s to transaction.", unit->id, job_type_to_string(type)); */
773 static void transaction_unlink_job(Transaction *tr, Job *j, bool delete_dependencies) {
777 if (j->transaction_prev)
778 j->transaction_prev->transaction_next = j->transaction_next;
779 else if (j->transaction_next)
780 hashmap_replace(tr->jobs, j->unit, j->transaction_next);
782 hashmap_remove_value(tr->jobs, j->unit, j);
784 if (j->transaction_next)
785 j->transaction_next->transaction_prev = j->transaction_prev;
787 j->transaction_prev = j->transaction_next = NULL;
789 while (j->subject_list)
790 job_dependency_free(j->subject_list);
792 while (j->object_list) {
793 Job *other = j->object_list->matters ? j->object_list->subject : NULL;
795 job_dependency_free(j->object_list);
797 if (other && delete_dependencies) {
798 log_debug("Deleting job %s/%s as dependency of job %s/%s",
799 other->unit->id, job_type_to_string(other->type),
800 j->unit->id, job_type_to_string(j->type));
801 transaction_delete_job(tr, other, delete_dependencies);
806 int transaction_add_job_and_dependencies(
814 bool ignore_requirements,
824 assert(type < _JOB_TYPE_MAX);
827 /* log_debug("Pulling in %s/%s from %s/%s", */
828 /* unit->id, job_type_to_string(type), */
829 /* by ? by->unit->id : "NA", */
830 /* by ? job_type_to_string(by->type) : "NA"); */
832 if (unit->load_state != UNIT_LOADED &&
833 unit->load_state != UNIT_ERROR &&
834 unit->load_state != UNIT_MASKED) {
835 dbus_set_error(e, BUS_ERROR_LOAD_FAILED, "Unit %s is not loaded properly.", unit->id);
839 if (type != JOB_STOP && unit->load_state == UNIT_ERROR) {
840 dbus_set_error(e, BUS_ERROR_LOAD_FAILED,
841 "Unit %s failed to load: %s. "
842 "See system logs and 'systemctl status %s' for details.",
844 strerror(-unit->load_error),
849 if (type != JOB_STOP && unit->load_state == UNIT_MASKED) {
850 dbus_set_error(e, BUS_ERROR_MASKED, "Unit %s is masked.", unit->id);
854 if (!unit_job_is_applicable(unit, type)) {
855 dbus_set_error(e, BUS_ERROR_JOB_TYPE_NOT_APPLICABLE, "Job type %s is not applicable for unit %s.", job_type_to_string(type), unit->id);
859 /* First add the job. */
860 ret = transaction_add_one_job(tr, type, unit, override, &is_new);
864 ret->ignore_order = ret->ignore_order || ignore_order;
866 /* Then, add a link to the job. */
868 if (!job_dependency_new(by, ret, matters, conflicts))
871 /* If the job has no parent job, it is the anchor job. */
872 assert(!tr->anchor_job);
873 tr->anchor_job = ret;
875 if (is_new && !ignore_requirements) {
878 /* If we are following some other unit, make sure we
879 * add all dependencies of everybody following. */
880 if (unit_following_set(ret->unit, &following) > 0) {
881 SET_FOREACH(dep, following, i) {
882 r = transaction_add_job_and_dependencies(tr, type, dep, ret, false, override, false, false, ignore_order, e);
884 log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
894 /* Finally, recursively add in all dependencies. */
895 if (type == JOB_START || type == JOB_RELOAD_OR_START) {
896 SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRES], i) {
897 r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, override, false, false, ignore_order, e);
907 SET_FOREACH(dep, ret->unit->dependencies[UNIT_BIND_TO], i) {
908 r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, override, false, false, ignore_order, e);
918 SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRES_OVERRIDABLE], i) {
919 r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, !override, override, false, false, ignore_order, e);
921 log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
928 SET_FOREACH(dep, ret->unit->dependencies[UNIT_WANTS], i) {
929 r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, false, false, false, false, ignore_order, e);
931 log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
938 SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUISITE], i) {
939 r = transaction_add_job_and_dependencies(tr, JOB_VERIFY_ACTIVE, dep, ret, true, override, false, false, ignore_order, e);
949 SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUISITE_OVERRIDABLE], i) {
950 r = transaction_add_job_and_dependencies(tr, JOB_VERIFY_ACTIVE, dep, ret, !override, override, false, false, ignore_order, e);
952 log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
959 SET_FOREACH(dep, ret->unit->dependencies[UNIT_CONFLICTS], i) {
960 r = transaction_add_job_and_dependencies(tr, JOB_STOP, dep, ret, true, override, true, false, ignore_order, e);
970 SET_FOREACH(dep, ret->unit->dependencies[UNIT_CONFLICTED_BY], i) {
971 r = transaction_add_job_and_dependencies(tr, JOB_STOP, dep, ret, false, override, false, false, ignore_order, e);
973 log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
982 if (type == JOB_STOP || type == JOB_RESTART || type == JOB_TRY_RESTART) {
984 SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRED_BY], i) {
985 r = transaction_add_job_and_dependencies(tr, type, dep, ret, true, override, false, false, ignore_order, e);
995 SET_FOREACH(dep, ret->unit->dependencies[UNIT_BOUND_BY], i) {
996 r = transaction_add_job_and_dependencies(tr, type, dep, ret, true, override, false, false, ignore_order, e);
1007 if (type == JOB_RELOAD || type == JOB_RELOAD_OR_START) {
1009 SET_FOREACH(dep, ret->unit->dependencies[UNIT_PROPAGATE_RELOAD_TO], i) {
1010 r = transaction_add_job_and_dependencies(tr, JOB_RELOAD, dep, ret, false, override, false, false, ignore_order, e);
1012 log_warning("Cannot add dependency reload job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
1020 /* JOB_VERIFY_STARTED, JOB_RELOAD require no dependency handling */
1029 int transaction_add_isolate_jobs(Transaction *tr, Manager *m) {
1038 HASHMAP_FOREACH_KEY(u, k, m->units, i) {
1040 /* ignore aliases */
1044 if (u->ignore_on_isolate)
1047 /* No need to stop inactive jobs */
1048 if (UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(u)) && !u->job)
1051 /* Is there already something listed for this? */
1052 if (hashmap_get(tr->jobs, u))
1055 r = transaction_add_job_and_dependencies(tr, JOB_STOP, u, tr->anchor_job, true, false, false, false, false, NULL);
1057 log_warning("Cannot add isolate job for unit %s, ignoring: %s", u->id, strerror(-r));
1063 Transaction *transaction_new(void) {
1066 tr = new0(Transaction, 1);
1070 tr->jobs = hashmap_new(trivial_hash_func, trivial_compare_func);
1079 void transaction_free(Transaction *tr) {
1080 assert(hashmap_isempty(tr->jobs));
1081 hashmap_free(tr->jobs);