Lines Matching defs:tr

30 static void transaction_unlink_job(Transaction *tr, Job *j, bool delete_dependencies);
32 static void transaction_delete_job(Transaction *tr, Job *j, bool delete_dependencies) {
33 assert(tr);
38 transaction_unlink_job(tr, j, delete_dependencies);
43 static void transaction_delete_unit(Transaction *tr, Unit *u) {
49 while ((j = hashmap_get(tr->jobs, u)))
50 transaction_delete_job(tr, j, true);
53 void transaction_abort(Transaction *tr) {
56 assert(tr);
58 while ((j = hashmap_first(tr->jobs)))
59 transaction_delete_job(tr, j, false);
61 assert(hashmap_isempty(tr->jobs));
89 static void transaction_merge_and_delete_job(Transaction *tr, Job *j, Job *other, JobType t) {
139 transaction_delete_job(tr, other, true);
157 static int delete_one_unmergeable_job(Transaction *tr, Job *j) {
228 transaction_delete_job(tr, d, true);
235 static int transaction_merge_jobs(Transaction *tr, sd_bus_error *e) {
240 assert(tr);
244 HASHMAP_FOREACH(j, tr->jobs, i) {
257 r = delete_one_unmergeable_job(tr, j);
275 HASHMAP_FOREACH(j, tr->jobs, i) {
284 if (tr->anchor_job == k) {
285 transaction_merge_and_delete_job(tr, k, j, t);
288 transaction_merge_and_delete_job(tr, j, k, t);
298 static void transaction_drop_redundant(Transaction *tr) {
306 assert(tr);
309 HASHMAP_FOREACH(j, tr->jobs, i) {
314 if (tr->anchor_job == k ||
321 transaction_delete_job(tr, j, false);
341 static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsigned generation, sd_bus_error *e) {
346 assert(tr);
381 if (!delete && hashmap_get(tr->jobs, k->unit) && !unit_matters_to_anchor(k->unit, k))
404 transaction_delete_unit(tr, delete->unit);
427 o = hashmap_get(tr->jobs, u);
437 r = transaction_verify_order_one(tr, o, j, generation, e);
449 static int transaction_verify_order(Transaction *tr, unsigned *generation, sd_bus_error *e) {
455 assert(tr);
463 HASHMAP_FOREACH(j, tr->jobs, i) {
464 r = transaction_verify_order_one(tr, j, NULL, g, e);
472 static void transaction_collect_garbage(Transaction *tr) {
476 assert(tr);
481 HASHMAP_FOREACH(j, tr->jobs, i) {
482 if (tr->anchor_job == j || j->object_list) {
491 transaction_delete_job(tr, j, true);
496 static int transaction_is_destructive(Transaction *tr, JobMode mode, sd_bus_error *e) {
500 assert(tr);
505 HASHMAP_FOREACH(j, tr->jobs, i) {
520 static void transaction_minimize_impact(Transaction *tr) {
524 assert(tr);
530 HASHMAP_FOREACH(j, tr->jobs, i) {
567 transaction_delete_job(tr, j, true);
573 static int transaction_apply(Transaction *tr, Manager *m, JobMode mode) {
587 if (hashmap_get(tr->jobs, j->unit))
597 HASHMAP_FOREACH(j, tr->jobs, i) {
607 while ((j = hashmap_steal_first(tr->jobs))) {
611 transaction_unlink_job(tr, j, false);
616 if (tr->anchor_job == j)
617 tr->anchor_job = installed_job;
633 HASHMAP_FOREACH(j, tr->jobs, i)
639 int transaction_activate(Transaction *tr, Manager *m, JobMode mode, sd_bus_error *e) {
645 assert(tr);
647 /* This applies the changes recorded in tr->jobs to
657 transaction_find_jobs_that_matter_to_anchor(tr->anchor_job, generation++);
663 transaction_minimize_impact(tr);
666 transaction_drop_redundant(tr);
672 transaction_collect_garbage(tr);
676 r = transaction_verify_order(tr, &generation, e);
693 r = transaction_merge_jobs(tr, e);
705 transaction_collect_garbage(tr);
712 transaction_drop_redundant(tr);
715 r = transaction_is_destructive(tr, mode, e);
722 r = transaction_apply(tr, m, mode);
726 assert(hashmap_isempty(tr->jobs));
745 static Job* transaction_add_one_job(Transaction *tr, JobType type, Unit *unit, bool *is_new) {
748 assert(tr);
755 f = hashmap_get(tr->jobs, unit);
774 j->irreversible = tr->irreversible;
778 if (hashmap_replace(tr->jobs, unit, f) < 0) {
792 static void transaction_unlink_job(Transaction *tr, Job *j, bool delete_dependencies) {
793 assert(tr);
799 hashmap_replace(tr->jobs, j->unit, j->transaction_next);
801 hashmap_remove_value(tr->jobs, j->unit, j);
821 transaction_delete_job(tr, other, delete_dependencies);
827 Transaction *tr,
842 assert(tr);
875 ret = transaction_add_one_job(tr, type, unit, &is_new);
887 assert(!tr->anchor_job);
888 tr->anchor_job = ret;
898 r = transaction_add_job_and_dependencies(tr, type, dep, ret, false, false, false, ignore_order, e);
911 r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, false, false, ignore_order, e);
921 r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, false, false, ignore_order, e);
931 r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, false, false, false, ignore_order, e);
943 r = transaction_add_job_and_dependencies(tr, JOB_VERIFY_ACTIVE, dep, ret, true, false, false, ignore_order, e);
953 r = transaction_add_job_and_dependencies(tr, JOB_STOP, dep, ret, true, true, false, ignore_order, e);
963 r = transaction_add_job_and_dependencies(tr, JOB_STOP, dep, ret, false, false, false, ignore_order, e);
998 r = transaction_add_job_and_dependencies(tr, nt, dep, ret, true, false, false, ignore_order, e);
1017 r = transaction_add_job_and_dependencies(tr, nt, dep, ret, false, false, false, ignore_order, e);
1036 int transaction_add_isolate_jobs(Transaction *tr, Manager *m) {
1042 assert(tr);
1059 if (hashmap_get(tr->jobs, u))
1062 r = transaction_add_job_and_dependencies(tr, JOB_STOP, u, tr->anchor_job, true, false, false, false, NULL);
1071 Transaction *tr;
1073 tr = new0(Transaction, 1);
1074 if (!tr)
1077 tr->jobs = hashmap_new(NULL);
1078 if (!tr->jobs) {
1079 free(tr);
1083 tr->irreversible = irreversible;
1085 return tr;
1088 void transaction_free(Transaction *tr) {
1089 assert(hashmap_isempty(tr->jobs));
1090 hashmap_free(tr->jobs);
1091 free(tr);