Track which job is the anchor in the transaction.
int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool override, DBusError *e, Job **_ret) {
int r;
int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool override, DBusError *e, Job **_ret) {
int r;
Transaction *tr;
assert(m);
Transaction *tr;
assert(m);
r = transaction_add_job_and_dependencies(tr, type, unit, NULL, true, override, false,
mode == JOB_IGNORE_DEPENDENCIES || mode == JOB_IGNORE_REQUIREMENTS,
r = transaction_add_job_and_dependencies(tr, type, unit, NULL, true, override, false,
mode == JOB_IGNORE_DEPENDENCIES || mode == JOB_IGNORE_REQUIREMENTS,
- mode == JOB_IGNORE_DEPENDENCIES, e, &ret);
+ mode == JOB_IGNORE_DEPENDENCIES, e);
if (r < 0)
goto tr_abort;
if (r < 0)
goto tr_abort;
if (r < 0)
goto tr_abort;
if (r < 0)
goto tr_abort;
- log_debug("Enqueued job %s/%s as %u", unit->id, job_type_to_string(type), (unsigned) ret->id);
+ log_debug("Enqueued job %s/%s as %u", unit->id, job_type_to_string(type), (unsigned) tr->anchor_job->id);
+ *_ret = tr->anchor_job;
transaction_free(tr);
return 0;
transaction_free(tr);
return 0;
bool conflicts,
bool ignore_requirements,
bool ignore_order,
bool conflicts,
bool ignore_requirements,
bool ignore_order,
- DBusError *e,
- Job **_ret) {
Job *ret;
JobDependency *l;
Iterator i;
Job *ret;
JobDependency *l;
Iterator i;
return -ENOMEM;
/* If the link has no subject job, it's the anchor link. */
return -ENOMEM;
/* If the link has no subject job, it's the anchor link. */
LIST_PREPEND(JobDependency, subject, tr->anchor, l);
LIST_PREPEND(JobDependency, subject, tr->anchor, l);
+ if (!tr->anchor_job)
+ tr->anchor_job = ret;
+ }
if (is_new && !ignore_requirements) {
Set *following;
if (is_new && !ignore_requirements) {
Set *following;
* add all dependencies of everybody following. */
if (unit_following_set(ret->unit, &following) > 0) {
SET_FOREACH(dep, following, i) {
* add all dependencies of everybody following. */
if (unit_following_set(ret->unit, &following) > 0) {
SET_FOREACH(dep, following, i) {
- r = transaction_add_job_and_dependencies(tr, type, dep, ret, false, override, false, false, ignore_order, e, NULL);
+ r = transaction_add_job_and_dependencies(tr, type, dep, ret, false, override, false, false, ignore_order, e);
if (r < 0) {
log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
if (r < 0) {
log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
/* Finally, recursively add in all dependencies. */
if (type == JOB_START || type == JOB_RELOAD_OR_START) {
SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRES], i) {
/* Finally, recursively add in all dependencies. */
if (type == JOB_START || type == JOB_RELOAD_OR_START) {
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, NULL);
+ r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, override, false, false, ignore_order, e);
if (r < 0) {
if (r != -EBADR)
goto fail;
if (r < 0) {
if (r != -EBADR)
goto fail;
}
SET_FOREACH(dep, ret->unit->dependencies[UNIT_BIND_TO], i) {
}
SET_FOREACH(dep, ret->unit->dependencies[UNIT_BIND_TO], i) {
- r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, override, false, false, ignore_order, e, NULL);
+ r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, override, false, false, ignore_order, e);
if (r < 0) {
if (r != -EBADR)
goto fail;
if (r < 0) {
if (r != -EBADR)
goto fail;
}
SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRES_OVERRIDABLE], i) {
}
SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRES_OVERRIDABLE], i) {
- r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, !override, override, false, false, ignore_order, e, NULL);
+ r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, !override, override, false, false, ignore_order, e);
if (r < 0) {
log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
if (r < 0) {
log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
}
SET_FOREACH(dep, ret->unit->dependencies[UNIT_WANTS], i) {
}
SET_FOREACH(dep, ret->unit->dependencies[UNIT_WANTS], i) {
- r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, false, false, false, false, ignore_order, e, NULL);
+ r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, false, false, false, false, ignore_order, e);
if (r < 0) {
log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
if (r < 0) {
log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
}
SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUISITE], i) {
}
SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUISITE], i) {
- r = transaction_add_job_and_dependencies(tr, JOB_VERIFY_ACTIVE, dep, ret, true, override, false, false, ignore_order, e, NULL);
+ r = transaction_add_job_and_dependencies(tr, JOB_VERIFY_ACTIVE, dep, ret, true, override, false, false, ignore_order, e);
if (r < 0) {
if (r != -EBADR)
goto fail;
if (r < 0) {
if (r != -EBADR)
goto fail;
}
SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUISITE_OVERRIDABLE], i) {
}
SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUISITE_OVERRIDABLE], i) {
- r = transaction_add_job_and_dependencies(tr, JOB_VERIFY_ACTIVE, dep, ret, !override, override, false, false, ignore_order, e, NULL);
+ r = transaction_add_job_and_dependencies(tr, JOB_VERIFY_ACTIVE, dep, ret, !override, override, false, false, ignore_order, e);
if (r < 0) {
log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
if (r < 0) {
log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
}
SET_FOREACH(dep, ret->unit->dependencies[UNIT_CONFLICTS], i) {
}
SET_FOREACH(dep, ret->unit->dependencies[UNIT_CONFLICTS], i) {
- r = transaction_add_job_and_dependencies(tr, JOB_STOP, dep, ret, true, override, true, false, ignore_order, e, NULL);
+ r = transaction_add_job_and_dependencies(tr, JOB_STOP, dep, ret, true, override, true, false, ignore_order, e);
if (r < 0) {
if (r != -EBADR)
goto fail;
if (r < 0) {
if (r != -EBADR)
goto fail;
}
SET_FOREACH(dep, ret->unit->dependencies[UNIT_CONFLICTED_BY], i) {
}
SET_FOREACH(dep, ret->unit->dependencies[UNIT_CONFLICTED_BY], i) {
- r = transaction_add_job_and_dependencies(tr, JOB_STOP, dep, ret, false, override, false, false, ignore_order, e, NULL);
+ r = transaction_add_job_and_dependencies(tr, JOB_STOP, dep, ret, false, override, false, false, ignore_order, e);
if (r < 0) {
log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
if (r < 0) {
log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
if (type == JOB_STOP || type == JOB_RESTART || type == JOB_TRY_RESTART) {
SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRED_BY], i) {
if (type == JOB_STOP || type == JOB_RESTART || type == JOB_TRY_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, NULL);
+ 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 (r < 0) {
if (r != -EBADR)
goto fail;
}
SET_FOREACH(dep, ret->unit->dependencies[UNIT_BOUND_BY], i) {
}
SET_FOREACH(dep, ret->unit->dependencies[UNIT_BOUND_BY], i) {
- r = transaction_add_job_and_dependencies(tr, type, dep, ret, true, override, false, false, ignore_order, e, NULL);
+ 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 (r < 0) {
if (r != -EBADR)
goto fail;
if (type == JOB_RELOAD || type == JOB_RELOAD_OR_START) {
SET_FOREACH(dep, ret->unit->dependencies[UNIT_PROPAGATE_RELOAD_TO], i) {
if (type == JOB_RELOAD || type == JOB_RELOAD_OR_START) {
SET_FOREACH(dep, ret->unit->dependencies[UNIT_PROPAGATE_RELOAD_TO], i) {
- r = transaction_add_job_and_dependencies(tr, JOB_RELOAD, dep, ret, false, override, false, false, ignore_order, e, NULL);
+ 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));
if (r < 0) {
log_warning("Cannot add dependency reload job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
/* JOB_VERIFY_STARTED, JOB_RELOAD require no dependency handling */
}
/* JOB_VERIFY_STARTED, JOB_RELOAD require no dependency handling */
}
- if (_ret)
- *_ret = ret;
-
if (hashmap_get(tr->jobs, u))
continue;
if (hashmap_get(tr->jobs, u))
continue;
- r = transaction_add_job_and_dependencies(tr, JOB_STOP, u, NULL, true, false, false, false, false, NULL, NULL);
+ r = transaction_add_job_and_dependencies(tr, JOB_STOP, u, NULL, true, false, false, false, false, NULL);
if (r < 0)
log_warning("Cannot add isolate job for unit %s, ignoring: %s", u->id, strerror(-r));
}
if (r < 0)
log_warning("Cannot add isolate job for unit %s, ignoring: %s", u->id, strerror(-r));
}
/* Jobs to be added */
Hashmap *jobs; /* Unit object => Job object list 1:1 */
JobDependency *anchor;
/* Jobs to be added */
Hashmap *jobs; /* Unit object => Job object list 1:1 */
JobDependency *anchor;
+ Job *anchor_job; /* the job the user asked for */
};
Transaction *transaction_new(void);
};
Transaction *transaction_new(void);
bool conflicts,
bool ignore_requirements,
bool ignore_order,
bool conflicts,
bool ignore_requirements,
bool ignore_order,
- DBusError *e,
- Job **_ret);
int transaction_activate(Transaction *tr, Manager *m, JobMode mode, DBusError *e);
int transaction_add_isolate_jobs(Transaction *tr, Manager *m);
void transaction_abort(Transaction *tr);
int transaction_activate(Transaction *tr, Manager *m, JobMode mode, DBusError *e);
int transaction_add_isolate_jobs(Transaction *tr, Manager *m);
void transaction_abort(Transaction *tr);