summaryrefslogtreecommitdiff
path: root/unit.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-04-06 16:32:07 +0200
committerLennart Poettering <lennart@poettering.net>2010-04-06 16:32:07 +0200
commitf278026d21e2ded46f7f91152d60842525e74956 (patch)
tree5d1e22f332a64f807a0750a1902a6724f16c89db /unit.c
parent8b44eabff0dd0dcbee1af637bc7d9d2b9dfcd427 (diff)
dbus: connect to bus as soon as the special dbus service is around
Diffstat (limited to 'unit.c')
-rw-r--r--unit.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/unit.c b/unit.c
index 10efd14c6a..1a0225a633 100644
--- a/unit.c
+++ b/unit.c
@@ -131,6 +131,13 @@ Unit *unit_new(Manager *m) {
return u;
}
+bool unit_has_name(Unit *u, const char *name) {
+ assert(u);
+ assert(name);
+
+ return !!set_get(u->meta.names, (char*) name);
+}
+
int unit_add_name(Unit *u, const char *text) {
UnitType t;
char *s;
@@ -906,6 +913,28 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns) {
else if (UNIT_IS_ACTIVE_OR_ACTIVATING(os) && UNIT_IS_INACTIVE_OR_DEACTIVATING(ns))
retroactively_stop_dependencies(u);
+ if (!UNIT_IS_ACTIVE_OR_RELOADING(os) && UNIT_IS_ACTIVE_OR_RELOADING(ns)) {
+
+ if (unit_has_name(u, SPECIAL_DBUS_SERVICE)) {
+ /* The bus just got started, hence try to connect to it. */
+ bus_init_system(u->meta.manager);
+ bus_init_api(u->meta.manager);
+ }
+
+ if (unit_has_name(u, SPECIAL_SYSLOG_SERVICE))
+ /* The syslog daemon just got started, hence try to connect to it. */
+ log_info("Syslog now available, this is where we should start logging to it.");
+
+ } else if (UNIT_IS_ACTIVE_OR_RELOADING(os) && !UNIT_IS_ACTIVE_OR_RELOADING(ns)) {
+
+ if (unit_has_name(u, SPECIAL_SYSLOG_SERVICE))
+ /* The syslog daemon just got terminated, hence try to disconnect from it. */
+ log_info("Syslog now gone, this is where we should stio logging to it.");
+
+ /* We don't care about D-Bus here, since we'll get an
+ * asynchronous notification for it anyway. */
+ }
+
/* Maybe we finished startup and are now ready for being
* stopped because unneeded? */
unit_check_uneeded(u);