X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Ftransaction.c;h=1f8d803aeb72b252628b3539225994191638f676;hp=aee155f5196070254d3aabee858c057ea8aeba56;hb=b3ac5f8cb98757416d8660023d6564a7c411f0a0;hpb=5273510e9f228a300ec6207d4502f1c6253aed5e diff --git a/src/core/transaction.c b/src/core/transaction.c index aee155f51..1f8d803ae 100644 --- a/src/core/transaction.c +++ b/src/core/transaction.c @@ -19,6 +19,9 @@ along with systemd; If not, see . ***/ +#include +#include + #include "transaction.h" #include "bus-errors.h" @@ -233,7 +236,7 @@ static int transaction_merge_jobs(Transaction *tr, DBusError *e) { t = j->type; LIST_FOREACH(transaction, k, j->transaction_next) { - if (job_type_merge(&t, k->type) >= 0) + if (job_type_merge_and_collapse(&t, k->type, j->unit) >= 0) continue; /* OK, we could not merge all jobs for this @@ -259,9 +262,9 @@ static int transaction_merge_jobs(Transaction *tr, DBusError *e) { JobType t = j->type; Job *k; - /* Merge all transactions */ + /* Merge all transaction jobs for j->unit */ LIST_FOREACH(transaction, k, j->transaction_next) - assert_se(job_type_merge(&t, k->type) == 0); + assert_se(job_type_merge_and_collapse(&t, k->type, j->unit) == 0); while ((k = j->transaction_next)) { if (tr->anchor_job == k) { @@ -693,6 +696,17 @@ int transaction_activate(Transaction *tr, Manager *m, JobMode mode, DBusError *e assert(hashmap_isempty(tr->jobs)); + if (!hashmap_isempty(m->jobs)) { + /* Are there any jobs now? Then make sure we have the + * idle pipe around. We don't really care too much + * whether this works or not, as the idle pipe is a + * feature for cosmetics, not actually useful for + * anything beyond that. */ + + if (m->idle_pipe[0] < 0 && m->idle_pipe[1] < 0) + pipe2(m->idle_pipe, O_NONBLOCK|O_CLOEXEC); + } + return 0; } @@ -795,6 +809,7 @@ int transaction_add_job_and_dependencies( assert(tr); assert(type < _JOB_TYPE_MAX); + assert(type < _JOB_TYPE_MAX_IN_TRANSACTION); assert(unit); /* log_debug("Pulling in %s/%s from %s/%s", */ @@ -845,7 +860,8 @@ int transaction_add_job_and_dependencies( assert(!tr->anchor_job); tr->anchor_job = ret; } - if (is_new && !ignore_requirements) { + + if (is_new && !ignore_requirements && type != JOB_NOP) { Set *following; /* If we are following some other unit, make sure we @@ -865,7 +881,7 @@ int transaction_add_job_and_dependencies( } /* Finally, recursively add in all dependencies. */ - if (type == JOB_START || type == JOB_RELOAD_OR_START || type == JOB_RESTART) { + if (type == JOB_START || type == JOB_RESTART) { SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRES], i) { r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, override, false, false, ignore_order, e); if (r < 0) { @@ -877,7 +893,7 @@ int transaction_add_job_and_dependencies( } } - SET_FOREACH(dep, ret->unit->dependencies[UNIT_BIND_TO], i) { + SET_FOREACH(dep, ret->unit->dependencies[UNIT_BINDS_TO], i) { r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, override, false, false, ignore_order, e); if (r < 0) { if (r != -EBADR) @@ -955,7 +971,7 @@ int transaction_add_job_and_dependencies( } - if (type == JOB_STOP || type == JOB_RESTART || type == JOB_TRY_RESTART) { + if (type == JOB_STOP || type == JOB_RESTART) { SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRED_BY], i) { r = transaction_add_job_and_dependencies(tr, type, dep, ret, true, override, false, false, ignore_order, e); @@ -978,11 +994,23 @@ int transaction_add_job_and_dependencies( dbus_error_free(e); } } + + SET_FOREACH(dep, ret->unit->dependencies[UNIT_CONSISTS_OF], i) { + r = transaction_add_job_and_dependencies(tr, type, dep, ret, true, override, false, false, ignore_order, e); + if (r < 0) { + if (r != -EBADR) + goto fail; + + if (e) + dbus_error_free(e); + } + } + } - if (type == JOB_RELOAD || type == JOB_RELOAD_OR_START) { + if (type == JOB_RELOAD) { - SET_FOREACH(dep, ret->unit->dependencies[UNIT_PROPAGATE_RELOAD_TO], i) { + SET_FOREACH(dep, ret->unit->dependencies[UNIT_PROPAGATES_RELOAD_TO], i) { r = transaction_add_job_and_dependencies(tr, JOB_RELOAD, dep, ret, false, override, false, false, ignore_order, e); if (r < 0) { log_warning("Cannot add dependency reload job for unit %s, ignoring: %s", dep->id, bus_error(e, r)); @@ -993,7 +1021,7 @@ int transaction_add_job_and_dependencies( } } - /* JOB_VERIFY_STARTED, JOB_RELOAD require no dependency handling */ + /* JOB_VERIFY_STARTED require no dependency handling */ } return 0;