summaryrefslogtreecommitdiffstats
path: root/src/unit.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-01-06 23:08:54 +0100
committerLennart Poettering <lennart@poettering.net>2012-01-06 23:08:54 +0100
commit57020a3abff20f176e9f0cbb982d7977119d6f08 (patch)
tree3b3d69307cecce0dc4ad25aa074c2a0db64bdfb6 /src/unit.h
parentservice: add dependencies on configured sockets (diff)
downloadsystemd-57020a3abff20f176e9f0cbb982d7977119d6f08.tar.xz
systemd-57020a3abff20f176e9f0cbb982d7977119d6f08.zip
unit: properly update references to units which are merged
When we merge units that some kind of object points to, those pointers might become invalidated, and needs to be updated. Introduce a UnitRef struct which links up all the unit references, to ensure corrected references. At the same time, drop configured_sockets in the Service object, and replace it by proper UNIT_TRIGGERS resp. UNIT_TRIGGERED_BY dependencies, which allow us to simplify a lot of code.
Diffstat (limited to '')
-rw-r--r--src/unit.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/unit.h b/src/unit.h
index b32c1a702e..4d83309591 100644
--- a/src/unit.h
+++ b/src/unit.h
@@ -32,6 +32,7 @@ typedef enum UnitType UnitType;
typedef enum UnitLoadState UnitLoadState;
typedef enum UnitActiveState UnitActiveState;
typedef enum UnitDependency UnitDependency;
+typedef struct UnitRef UnitRef;
#include "set.h"
#include "util.h"
@@ -119,6 +120,10 @@ enum UnitDependency {
/* On Failure */
UNIT_ON_FAILURE,
+ /* Triggers (i.e. a socket triggers a service) */
+ UNIT_TRIGGERS,
+ UNIT_TRIGGERED_BY,
+
/* Reference information for GC logic */
UNIT_REFERENCES, /* Inverse of 'references' is 'referenced_by' */
UNIT_REFERENCED_BY,
@@ -156,6 +161,9 @@ struct Meta {
usec_t job_timeout;
+ /* References to this */
+ LIST_HEAD(UnitRef, refs);
+
/* Conditions to check */
LIST_HEAD(Condition, conditions);
@@ -237,6 +245,15 @@ struct Meta {
bool in_audit:1;
};
+struct UnitRef {
+ /* Keeps tracks of references to a unit. This is useful so
+ * that we can merge two units if necessary and correct all
+ * references to them */
+
+ Unit* unit;
+ LIST_FIELDS(UnitRef, refs);
+};
+
#include "service.h"
#include "timer.h"
#include "socket.h"
@@ -536,6 +553,11 @@ bool unit_condition_test(Unit *u);
UnitFileState unit_get_unit_file_state(Unit *u);
+Unit* unit_ref_set(UnitRef *ref, Unit *u);
+void unit_ref_unset(UnitRef *ref);
+
+#define UNIT_DEREF(ref) ((ref).unit)
+
const char *unit_load_state_to_string(UnitLoadState i);
UnitLoadState unit_load_state_from_string(const char *s);