summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/dbus-job.h2
-rw-r--r--src/core/dbus-unit.h1
-rw-r--r--src/core/service.c2
-rw-r--r--src/core/unit.c9
-rw-r--r--src/core/unit.h4
-rw-r--r--src/test/test-engine.c6
-rw-r--r--src/test/test-job-type.c1
7 files changed, 11 insertions, 14 deletions
diff --git a/src/core/dbus-job.h b/src/core/dbus-job.h
index c9f6fc7187..380e117fca 100644
--- a/src/core/dbus-job.h
+++ b/src/core/dbus-job.h
@@ -4,7 +4,7 @@
#include "sd-bus.h"
#include "sd-bus-vtable.h"
-#include "job.h"
+#include "unit.h"
extern const sd_bus_vtable bus_job_vtable[];
diff --git a/src/core/dbus-unit.h b/src/core/dbus-unit.h
index 24abf3c088..91711311a7 100644
--- a/src/core/dbus-unit.h
+++ b/src/core/dbus-unit.h
@@ -4,7 +4,6 @@
#include "sd-bus.h"
#include "sd-bus-vtable.h"
-#include "job.h"
#include "unit.h"
extern const sd_bus_vtable bus_unit_vtable[];
diff --git a/src/core/service.c b/src/core/service.c
index 71befcddc8..8e313f8e90 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -2245,7 +2245,7 @@ static void service_enter_restart(Service *s) {
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.");
diff --git a/src/core/unit.c b/src/core/unit.c
index b9fb7dbc0e..71fe7a6e23 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -4022,7 +4022,7 @@ bool unit_stop_pending(Unit *u) {
* 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) {
@@ -4057,12 +4057,7 @@ bool unit_active_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) {
diff --git a/src/core/unit.h b/src/core/unit.h
index 3b0042a9eb..793ee638a6 100644
--- a/src/core/unit.h
+++ b/src/core/unit.h
@@ -842,6 +842,10 @@ const char *unit_label_path(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);
diff --git a/src/test/test-engine.c b/src/test/test-engine.c
index 633cc42534..1064811497 100644
--- a/src/test/test-engine.c
+++ b/src/test/test-engine.c
@@ -106,9 +106,9 @@ int main(int argc, char *argv[]) {
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");
diff --git a/src/test/test-job-type.c b/src/test/test-job-type.c
index d51e0d94fd..33a95c6b52 100644
--- a/src/test/test-job-type.c
+++ b/src/test/test-job-type.c
@@ -2,7 +2,6 @@
#include <stdio.h>
-#include "job.h"
#include "service.h"
#include "unit.h"