diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2013-02-22 11:21:37 +0100 |
---|---|---|
committer | Michal Schmidt <mschmidt@redhat.com> | 2013-02-22 16:06:17 +0100 |
commit | 23ade460e5a118daa575a961b405d089f95e0617 (patch) | |
tree | b10d6c6ff9f7da39c0dac2ae09540fe63c2cf472 /src/core/transaction.c | |
parent | b7cf6049a36dfd8e5f3c6420243eb49d348dbd2f (diff) |
core, systemctl: add support for irreversible jobs
Add a new job mode: replace-irreversibly. Jobs enqueued using this mode
cannot be implicitly canceled by later enqueued conflicting jobs.
They can however still be canceled with an explicit "systemctl cancel"
call.
Diffstat (limited to 'src/core/transaction.c')
-rw-r--r-- | src/core/transaction.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/core/transaction.c b/src/core/transaction.c index dbc30af7d1..0329366350 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; @@ -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."); @@ -709,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 */ @@ -770,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); @@ -1106,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); @@ -1119,6 +1119,8 @@ Transaction *transaction_new(void) { return NULL; } + tr->irreversible = irreversible; + return tr; } |