#include "sd-bus.h"
#include "sd-bus-vtable.h"
-#include "job.h"
+#include "unit.h"
extern const sd_bus_vtable bus_job_vtable[];
#include "sd-bus.h"
#include "sd-bus-vtable.h"
-#include "job.h"
#include "unit.h"
extern const sd_bus_vtable bus_unit_vtable[];
assert(s);
- if (UNIT(s)->job && UNIT(s)->job->type == JOB_STOP) {
+ if (unit_has_job_type(UNIT(s), JOB_STOP)) {
/* Don't restart things if we are going down anyway */
log_unit_info(UNIT(s), "Stop job pending for unit, delaying automatic restart.");
* different from unit_inactive_or_pending() which checks both
* the current state and for a queued job. */
- return u->job && u->job->type == JOB_STOP;
+ return unit_has_job_type(u, JOB_STOP);
}
bool unit_inactive_or_pending(Unit *u) {
bool unit_will_restart_default(Unit *u) {
assert(u);
- if (!u->job)
- return false;
- if (u->job->type == JOB_START)
- return true;
-
- return false;
+ return unit_has_job_type(u, JOB_START);
}
bool unit_will_restart(Unit *u) {
int unit_pid_attachable(Unit *unit, pid_t pid, sd_bus_error *error);
+static inline bool unit_has_job_type(Unit *u, JobType type) {
+ return u && u->job && u->job->type == type;
+}
+
/* unit_log_skip is for cases like ExecCondition= where a unit is considered "done"
* after some execution, rather than succeeded or failed. */
void unit_log_skip(Unit *u, const char *result);
printf("Test11: (Start/stop job ordering, execution cycle)\n");
assert_se(manager_add_job(m, JOB_START, i, JOB_FAIL, NULL, NULL, &j) == 0);
- assert_se(a->job && a->job->type == JOB_STOP);
- assert_se(d->job && d->job->type == JOB_STOP);
- assert_se(b->job && b->job->type == JOB_START);
+ assert_se(unit_has_job_type(a, JOB_STOP));
+ assert_se(unit_has_job_type(d, JOB_STOP));
+ assert_se(unit_has_job_type(b, JOB_START));
manager_dump_jobs(m, stdout, "\t");
printf("Load6:\n");
#include <stdio.h>
-#include "job.h"
#include "service.h"
#include "unit.h"