diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-04-23 15:53:16 -0300 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-04-23 16:00:32 -0300 |
commit | 3ecaa09bccd8a59c9f1e06756a1334a162206dc4 (patch) | |
tree | 5db15dc8f6fe6ea17e0d2449b8fee015b6066f47 /src/core/unit.h | |
parent | a34cb32e54ed51125957f69622efef30f42d5fae (diff) |
unit: rework trigger dependency logic
Instead of having explicit type-specific callbacks that inform the
triggering unit when a triggered unit changes state, make this generic
so that state changes are forwarded betwee any triggered and triggering
unit.
Also, get rid of UnitRef references from automount, timer, path units,
to the units they trigger and rely exclsuively on UNIT_TRIGGER type
dendencies.
Diffstat (limited to 'src/core/unit.h')
-rw-r--r-- | src/core/unit.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/core/unit.h b/src/core/unit.h index a972a31366..51a8364d63 100644 --- a/src/core/unit.h +++ b/src/core/unit.h @@ -352,7 +352,7 @@ struct UnitVTable { /* Called whenever a process of this unit sends us a message */ void (*notify_message)(Unit *u, pid_t pid, char **tags); - /* Called whenever a name thus Unit registered for comes or + /* Called whenever a name this Unit registered for comes or * goes away. */ void (*bus_name_owner_change)(Unit *u, const char *name, const char *old_owner, const char *new_owner); @@ -368,6 +368,10 @@ struct UnitVTable { /* Return the set of units that are following each other */ int (*following_set)(Unit *u, Set **s); + /* Invoked each time a unit this unit is triggering changes + * state or gains/loses a job */ + void (*trigger_notify)(Unit *u, Unit *trigger); + /* Called whenever CLOCK_REALTIME made a jump */ void (*time_change)(Unit *u); @@ -417,6 +421,8 @@ 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_TRIGGER(u) ((Unit*) set_first((u)->dependencies[UNIT_TRIGGERS])) + DEFINE_CAST(SOCKET, Socket); DEFINE_CAST(TIMER, Timer); DEFINE_CAST(SERVICE, Service); @@ -540,7 +546,8 @@ char *unit_default_cgroup_path(Unit *u); int unit_following_set(Unit *u, Set **s); -void unit_trigger_on_failure(Unit *u); +void unit_start_on_failure(Unit *u); +void unit_trigger_notify(Unit *u); bool unit_condition_test(Unit *u); |