[systemd-commits] src/dbus.c src/dbus.h src/manager.c src/unit.c TODO

Lennart Poettering lennart at kemper.freedesktop.org
Thu Jan 20 10:43:47 PST 2011


 TODO          |    2 --
 src/dbus.c    |   12 ++++++++----
 src/dbus.h    |    2 +-
 src/manager.c |    4 ++--
 src/unit.c    |    2 +-
 5 files changed, 12 insertions(+), 10 deletions(-)

New commits:
commit 3996fbe2a2a212d9ac983950602cc09db55d77ef
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 20 19:43:38 2011 +0100

    dbus: don't try to connect to the system bus before it is actually up

diff --git a/TODO b/TODO
index 4e8c6d1..57802a6 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,5 @@
 Bugs:
 
-* Don't try to connect to dbus during early boot
-
 * sometimes processes seem to remain when we kill a service
   http://lists.fedoraproject.org/pipermail/devel/2011-January/147559.html
 
diff --git a/src/dbus.c b/src/dbus.c
index 48051f2..d7b80ba 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -982,7 +982,7 @@ fail:
         return r;
 }
 
-int bus_init(Manager *m) {
+int bus_init(Manager *m, bool try_bus_connect) {
         int r;
 
         if (set_ensure_allocated(&m->bus_connections, trivial_hash_func, trivial_compare_func) < 0 ||
@@ -1003,9 +1003,13 @@ int bus_init(Manager *m) {
                         return -ENOMEM;
                 }
 
-        if ((r = bus_init_system(m)) < 0 ||
-            (r = bus_init_api(m)) < 0 ||
-            (r = bus_init_private(m)) < 0)
+        if (try_bus_connect) {
+                if ((r = bus_init_system(m)) < 0 ||
+                    (r = bus_init_api(m)) < 0)
+                        return r;
+        }
+
+        if ((r = bus_init_private(m)) < 0)
                 return r;
 
         return 0;
diff --git a/src/dbus.h b/src/dbus.h
index 7c0da33..d0a9e8e 100644
--- a/src/dbus.h
+++ b/src/dbus.h
@@ -69,7 +69,7 @@ typedef struct BusProperty {
         " </method>\n"                                                  \
         "</interface>\n"
 
-int bus_init(Manager *m);
+int bus_init(Manager *m, bool try_bus_connect);
 void bus_done(Manager *m);
 
 unsigned bus_dispatch(Manager *m);
diff --git a/src/manager.c b/src/manager.c
index 6284706..013b26b 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -259,7 +259,7 @@ int manager_new(ManagerRunningAs running_as, Manager **_m) {
                 goto fail;
 
         /* Try to connect to the busses, if possible. */
-        if ((r = bus_init(m)) < 0)
+        if ((r = bus_init(m, running_as != MANAGER_SYSTEM)) < 0)
                 goto fail;
 
 #ifdef HAVE_AUDIT
@@ -2102,7 +2102,7 @@ static int manager_process_signal_fd(Manager *m) {
 
                         if (!u || UNIT_IS_ACTIVE_OR_RELOADING(unit_active_state(u))) {
                                 log_info("Trying to reconnect to bus...");
-                                bus_init(m);
+                                bus_init(m, true);
                         }
 
                         if (!u || !UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(u))) {
diff --git a/src/unit.c b/src/unit.c
index 9dd0267..a7e6714 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -1194,7 +1194,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
                         /* The bus just might have become available,
                          * hence try to connect to it, if we aren't
                          * yet connected. */
-                        bus_init(u->meta.manager);
+                        bus_init(u->meta.manager, true);
 
                 if (unit_has_name(u, SPECIAL_SYSLOG_SERVICE))
                         /* The syslog daemon just might have become



More information about the systemd-commits mailing list