summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-04-14 02:23:51 +0200
committerLennart Poettering <lennart@poettering.net>2011-04-16 02:03:34 +0200
commit4fe60156fc45e34c7bcba4779123e15620532dff (patch)
tree871ed78403cc1376e98c97a3bab9ab7e7f219fee
parentc8f4d7642b743c79328e10e8fb2d9b58e9f6b999 (diff)
manager: drop all pending jobs when isolating
-rw-r--r--src/manager.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/manager.c b/src/manager.c
index dfd33b08f4..495c8e6ba3 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -1187,13 +1187,27 @@ static void transaction_minimize_impact(Manager *m) {
} while (again);
}
-static int transaction_apply(Manager *m) {
+static int transaction_apply(Manager *m, JobMode mode) {
Iterator i;
Job *j;
int r;
/* Moves the transaction jobs to the set of active jobs */
+ if (mode == JOB_ISOLATE) {
+
+ /* When isolating first kill all installed jobs which
+ * aren't part of the new transaction */
+ HASHMAP_FOREACH(j, m->jobs, i) {
+ assert(j->installed);
+
+ if (hashmap_get(m->transaction_jobs, j->unit))
+ continue;
+
+ job_finish_and_invalidate(j, JOB_CANCELED);
+ }
+ }
+
HASHMAP_FOREACH(j, m->transaction_jobs, i) {
/* Assume merged */
assert(!j->transaction_prev);
@@ -1322,7 +1336,7 @@ static int transaction_activate(Manager *m, JobMode mode, DBusError *e) {
}
/* Tenth step: apply changes */
- if ((r = transaction_apply(m)) < 0) {
+ if ((r = transaction_apply(m, mode)) < 0) {
log_warning("Failed to apply transaction: %s", strerror(-r));
goto rollback;
}