X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Ftransaction.c;h=203070fa2697f90f6e75989fbbff29b722d1b8db;hb=da7e457c5b9339721454ae8401a03ffdd781e6a9;hp=03293663501fe14a27e6d831853d86479e782eb1;hpb=23ade460e5a118daa575a961b405d089f95e0617;p=elogind.git diff --git a/src/core/transaction.c b/src/core/transaction.c index 032936635..203070fa2 100644 --- a/src/core/transaction.c +++ b/src/core/transaction.c @@ -24,6 +24,7 @@ #include "transaction.h" #include "bus-errors.h" +#include "dbus-common.h" static void transaction_unlink_job(Transaction *tr, Job *j, bool delete_dependencies); @@ -139,7 +140,7 @@ static void transaction_merge_and_delete_job(Transaction *tr, Job *j, Job *other transaction_delete_job(tr, other, true); } -static bool job_is_conflicted_by(Job *j) { +_pure_ static bool job_is_conflicted_by(Job *j) { JobDependency *l; assert(j); @@ -319,7 +320,7 @@ rescan: } } -static bool unit_matters_to_anchor(Unit *u, Job *j) { +_pure_ static bool unit_matters_to_anchor(Unit *u, Job *j) { assert(u); assert(!j->transaction_prev); @@ -343,7 +344,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi assert(!j->transaction_prev); /* Does a recursive sweep through the ordering graph, looking - * for a cycle. If we find cycle we try to break it. */ + * for a cycle. If we find a cycle we try to break it. */ /* Have we seen this before? */ if (j->generation == generation) { @@ -370,7 +371,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi /* logging for j not k here here to provide consistent narrative */ log_info_unit(j->unit->id, - "Walked on cycle path to %s/%s", + "Found dependency on %s/%s", k->unit->id, job_type_to_string(k->type)); if (!delete && @@ -396,8 +397,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; } @@ -732,8 +733,11 @@ int transaction_activate(Transaction *tr, Manager *m, JobMode mode, DBusError *e * feature for cosmetics, not actually useful for * anything beyond that. */ - if (m->idle_pipe[0] < 0 && m->idle_pipe[1] < 0) + if (m->idle_pipe[0] < 0 && m->idle_pipe[1] < 0 && + m->idle_pipe[2] < 0 && m->idle_pipe[3] < 0) { pipe2(m->idle_pipe, O_NONBLOCK|O_CLOEXEC); + pipe2(m->idle_pipe + 2, O_NONBLOCK|O_CLOEXEC); + } } return 0; @@ -850,6 +854,7 @@ int transaction_add_job_and_dependencies( if (unit->load_state != UNIT_LOADED && unit->load_state != UNIT_ERROR && + unit->load_state != UNIT_NOT_FOUND && unit->load_state != UNIT_MASKED) { dbus_set_error(e, BUS_ERROR_LOAD_FAILED, "Unit %s is not loaded properly.", unit->id); return -EINVAL; @@ -865,6 +870,14 @@ int transaction_add_job_and_dependencies( return -EINVAL; } + if (type != JOB_STOP && unit->load_state == UNIT_NOT_FOUND) { + dbus_set_error(e, BUS_ERROR_LOAD_FAILED, + "Unit %s failed to load: %s.", + unit->id, + strerror(-unit->load_error)); + return -EINVAL; + } + if (type != JOB_STOP && unit->load_state == UNIT_MASKED) { dbus_set_error(e, BUS_ERROR_MASKED, "Unit %s is masked.", unit->id); return -EADDRNOTAVAIL;