X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=unit.c;h=93c0d8d61a29bb442550d419e2331cbb5afb12c1;hp=10efd14c6a39db11b9d99f6056c24a9f217d882d;hb=f170852aea19408cfefcd1b9df4aa8942dbbca98;hpb=23a177ef7c8c38c238ef06666f900f581b48298f diff --git a/unit.c b/unit.c index 10efd14c6..93c0d8d61 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_open_syslog(); + + } 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_close_syslog(); + + /* 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);