diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-08-28 17:14:59 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-08-31 13:20:43 +0200 |
commit | 35b7ff80e29524cb01f881ca6d52c669970c88f1 (patch) | |
tree | b041bd8084e481a38760152ebf97579656b2c478 /src | |
parent | 6513d561ce4c894ea4e29612a2ed62c8310a164f (diff) |
unit: add new macros to test for unit contexts
Diffstat (limited to 'src')
-rw-r--r-- | src/core/cgroup.c | 5 | ||||
-rw-r--r-- | src/core/dbus-unit.c | 2 | ||||
-rw-r--r-- | src/core/dbus.c | 2 | ||||
-rw-r--r-- | src/core/unit.c | 2 | ||||
-rw-r--r-- | src/core/unit.h | 4 |
5 files changed, 8 insertions, 7 deletions
diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 6474e08bd2..c26807ba2b 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -806,12 +806,9 @@ static void unit_queue_siblings(Unit *u) { } int unit_realize_cgroup(Unit *u) { - CGroupContext *c; - assert(u); - c = unit_get_cgroup_context(u); - if (!c) + if (!UNIT_HAS_CGROUP_CONTEXT(u)) return 0; /* So, here's the deal: when realizing the cgroups for this diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index 42bb653cc1..91c31987fe 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -965,7 +965,7 @@ static int bus_unit_set_transient_property( return 1; - } else if (streq(name, "Slice") && unit_get_cgroup_context(u)) { + } else if (streq(name, "Slice") && UNIT_HAS_CGROUP_CONTEXT(u)) { const char *s; r = sd_bus_message_read(message, "s", &s); diff --git a/src/core/dbus.c b/src/core/dbus.c index d091aa5419..7ad16aa42b 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -381,7 +381,7 @@ static int bus_unit_cgroup_find(sd_bus *bus, const char *path, const char *inter if (!streq_ptr(interface, unit_dbus_interface_from_type(u->type))) return 0; - if (!unit_get_cgroup_context(u)) + if (!UNIT_HAS_CGROUP_CONTEXT(u)) return 0; *found = u; diff --git a/src/core/unit.c b/src/core/unit.c index a6b56e2998..2ad49fd50b 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -1122,7 +1122,7 @@ static int unit_add_target_dependencies(Unit *u) { static int unit_add_slice_dependencies(Unit *u) { assert(u); - if (!unit_get_cgroup_context(u)) + if (!UNIT_HAS_CGROUP_CONTEXT(u)) return 0; if (UNIT_ISSET(u->slice)) diff --git a/src/core/unit.h b/src/core/unit.h index f53b7f6da1..8da12356f8 100644 --- a/src/core/unit.h +++ b/src/core/unit.h @@ -439,6 +439,10 @@ extern const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX]; /* For casting the various unit types into a unit */ #define UNIT(u) (&(u)->meta) +#define UNIT_HAS_EXEC_CONTEXT(u) (UNIT_VTABLE(u)->exec_context_offset > 0) +#define UNIT_HAS_CGROUP_CONTEXT(u) (UNIT_VTABLE(u)->cgroup_context_offset > 0) +#define UNIT_HAS_KILL_CONTEXT(u) (UNIT_VTABLE(u)->kill_context_offset > 0) + #define UNIT_TRIGGER(u) ((Unit*) set_first((u)->dependencies[UNIT_TRIGGERS])) DEFINE_CAST(SERVICE, Service); |