]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: for queued reload message there is no need to store the bus explicitly
authorLennart Poettering <lennart@poettering.net>
Wed, 29 Apr 2015 17:02:08 +0000 (19:02 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 29 Apr 2015 17:02:08 +0000 (19:02 +0200)
After all it can be derived from the message directly, and already is.

src/core/dbus-manager.c
src/core/dbus.c
src/core/manager.h

index 632529fcbc046ed71f9bd897151a436fbd55721f..18a379f8c4af4a17ef805518515259b33c613c12 100644 (file)
@@ -1166,7 +1166,6 @@ static int method_reload(sd_bus_message *message, void *userdata, sd_bus_error *
         if (r < 0)
                 return r;
 
-        m->queued_message_bus = sd_bus_ref(sd_bus_message_get_bus(message));
         m->exit_code = MANAGER_RELOAD;
 
         return 1;
index 8d72502a1af5fa69fd7481308917413ff9b7b42e..d1843aa29026b9e5604e4a6e56fe2086eac56352 100644 (file)
@@ -55,18 +55,15 @@ int bus_send_queued_message(Manager *m) {
         if (!m->queued_message)
                 return 0;
 
-        assert(m->queued_message_bus);
-
         /* If we cannot get rid of this message we won't dispatch any
          * D-Bus messages, so that we won't end up wanting to queue
          * another message. */
 
-        r = sd_bus_send(m->queued_message_bus, m->queued_message, NULL);
+        r = sd_bus_send(NULL, m->queued_message, NULL);
         if (r < 0)
                 log_warning_errno(r, "Failed to send queued message: %m");
 
         m->queued_message = sd_bus_message_unref(m->queued_message);
-        m->queued_message_bus = sd_bus_unref(m->queued_message_bus);
 
         return 0;
 }
@@ -1031,12 +1028,8 @@ static void destroy_bus(Manager *m, sd_bus **bus) {
                         j->clients = sd_bus_track_unref(j->clients);
 
         /* Get rid of queued message on this bus */
-        if (m->queued_message_bus == *bus) {
-                m->queued_message_bus = sd_bus_unref(m->queued_message_bus);
-
-                if (m->queued_message)
-                        m->queued_message = sd_bus_message_unref(m->queued_message);
-        }
+        if (m->queued_message && sd_bus_message_get_bus(m->queued_message) == *bus)
+                m->queued_message = sd_bus_message_unref(m->queued_message);
 
         /* Possibly flush unwritten data, but only if we are
          * unprivileged, since we don't want to sync here */
index a1caab4d4e52db1900da049b29cbf1ce08a5f50e..a9834a9def0e180ca8e8dc021282ef1233e06fc2 100644 (file)
@@ -199,11 +199,9 @@ struct Manager {
         sd_bus_track *subscribed;
         char **deserialized_subscribed;
 
-        sd_bus_message *queued_message; /* This is used during reloading:
-                                      * before the reload we queue the
-                                      * reply message here, and
-                                      * afterwards we send it */
-        sd_bus *queued_message_bus; /* The connection to send the queued message on */
+        /* This is used during reloading: before the reload we queue
+         * the reply message here, and afterwards we send it */
+        sd_bus_message *queued_message;
 
         Hashmap *watch_bus;  /* D-Bus names => Unit object n:1 */