X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Ftransaction.c;h=4a8d90e6e569692c14f5890eae89ad69033a0cc3;hp=1854047afdff8a299b87355614b1733e6913be6c;hb=7f602784de4fd378120e8ebfe6d830862b9cae03;hpb=66870f90dec9b5bf4ad76f9757fafce703560a67 diff --git a/src/core/transaction.c b/src/core/transaction.c index 1854047af..4a8d90e6e 100644 --- a/src/core/transaction.c +++ b/src/core/transaction.c @@ -97,6 +97,7 @@ static void transaction_merge_and_delete_job(Transaction *tr, Job *j, Job *other j->type = t; j->state = JOB_WAITING; j->override = j->override || other->override; + j->irreversible = j->irreversible || other->irreversible; j->matters_to_anchor = j->matters_to_anchor || other->matters_to_anchor; @@ -395,8 +396,8 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi "Job %s/%s deleted to break ordering cycle starting with %s/%s", delete->unit->id, job_type_to_string(delete->type), j->unit->id, job_type_to_string(j->type)); - status_printf(ANSI_HIGHLIGHT_RED_ON " SKIP " ANSI_HIGHLIGHT_OFF, true, - "Ordering cycle found, skipping %s", unit_description(delete->unit)); + unit_status_printf(delete->unit, ANSI_HIGHLIGHT_RED_ON " SKIP " ANSI_HIGHLIGHT_OFF, + "Ordering cycle found, skipping %s"); transaction_delete_unit(tr, delete->unit); return -EAGAIN; } @@ -488,7 +489,7 @@ rescan: } } -static int transaction_is_destructive(Transaction *tr, DBusError *e) { +static int transaction_is_destructive(Transaction *tr, JobMode mode, DBusError *e) { Iterator i; Job *j; @@ -503,7 +504,7 @@ static int transaction_is_destructive(Transaction *tr, DBusError *e) { assert(!j->transaction_prev); assert(!j->transaction_next); - if (j->unit->job && + if (j->unit->job && (mode == JOB_FAIL || j->unit->job->irreversible) && !job_type_is_superset(j->type, j->unit->job->type)) { dbus_set_error(e, BUS_ERROR_TRANSACTION_IS_DESTRUCTIVE, "Transaction is destructive."); @@ -620,6 +621,7 @@ static int transaction_apply(Transaction *tr, Manager *m, JobMode mode) { job_add_to_run_queue(j); job_add_to_dbus_queue(j); job_start_timer(j); + job_shutdown_magic(j); } return 0; @@ -708,12 +710,10 @@ int transaction_activate(Transaction *tr, Manager *m, JobMode mode, DBusError *e transaction_drop_redundant(tr); /* Ninth step: check whether we can actually apply this */ - if (mode == JOB_FAIL) { - r = transaction_is_destructive(tr, e); - if (r < 0) { - log_notice("Requested transaction contradicts existing jobs: %s", bus_error(e, r)); - return r; - } + r = transaction_is_destructive(tr, mode, e); + if (r < 0) { + log_notice("Requested transaction contradicts existing jobs: %s", bus_error(e, r)); + return r; } /* Tenth step: apply changes */ @@ -769,6 +769,7 @@ static Job* transaction_add_one_job(Transaction *tr, JobType type, Unit *unit, b j->marker = NULL; j->matters_to_anchor = false; j->override = override; + j->irreversible = tr->irreversible; LIST_PREPEND(Job, transaction, f, j); @@ -1105,7 +1106,7 @@ int transaction_add_isolate_jobs(Transaction *tr, Manager *m) { return 0; } -Transaction *transaction_new(void) { +Transaction *transaction_new(bool irreversible) { Transaction *tr; tr = new0(Transaction, 1); @@ -1118,6 +1119,8 @@ Transaction *transaction_new(void) { return NULL; } + tr->irreversible = irreversible; + return tr; }