]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
unit: add new macros to test for unit contexts
authorLennart Poettering <lennart@poettering.net>
Fri, 28 Aug 2015 15:14:59 +0000 (17:14 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 31 Aug 2015 11:20:43 +0000 (13:20 +0200)
src/core/cgroup.c
src/core/dbus-unit.c
src/core/dbus.c
src/core/unit.c
src/core/unit.h

index 6474e08bd2b331913312207bc4d4e0813a9905ec..c26807ba2b580922ee54f6b680675dd8d1cded8c 100644 (file)
@@ -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
index 42bb653cc1ff4a70435f3ffa9567e6a6b78a7bcb..91c31987fe85bfee0a909e37825879f406193bd6 100644 (file)
@@ -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);
index d091aa5419ed651cfe746e6ce823eb062d560e06..7ad16aa42b281860eeed9797e77995ca6c75e503 100644 (file)
@@ -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;
index a6b56e29988a8df12b6006bb25e06d75ad26213c..2ad49fd50b45f1c4d3ba3edd091f71bc84dbc195 100644 (file)
@@ -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))
index f53b7f6da153df8ec8dcee368cee23a809a53c76..8da12356f89f11d691732002440287c3a5d0c22c 100644 (file)
@@ -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);