]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: whenever we allocate a new bus object, close it before dropping final ref
authorLennart Poettering <lennart@poettering.net>
Thu, 17 Jan 2019 15:07:22 +0000 (16:07 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 17 Jan 2019 15:12:38 +0000 (16:12 +0100)
This doesn't really change much, but feels more correct to do, as it
ensures that all messages currently queued in the bus connections are
definitely unreffed and thus destryoing of the connection object will
follow immediately.

Strictly speaking this change is entirely unnecessary, since nothing
else could have acquired a ref to the connection and queued a message
in, however, now that we have the new sd_bus_close_unref() helper it
makes a lot of sense to use it here, to ensure that whatever happens
nothing that might have been queued fucks with us.

src/busctl/busctl.c
src/core/dbus.c
src/machine/machine-dbus.c
src/shared/bus-util.c

index 96b4177495f23a5a33e18a7c1715b48d035b9afc..08d9e70c96088737009431343092f9179edaf2f8 100644 (file)
@@ -67,7 +67,7 @@ static int json_transform_message(sd_bus_message *m, JsonVariant **ret);
 static void json_dump_with_flags(JsonVariant *v, FILE *f);
 
 static int acquire_bus(bool set_monitor, sd_bus **ret) {
-        _cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
+        _cleanup_(sd_bus_close_unrefp) sd_bus *bus = NULL;
         int r;
 
         r = sd_bus_new(&bus);
index ae595e0567e58a61818e6864676ce5f527d698a5..bab4a1a81b6e89ff24bc642e0cd79a49ccc7a2b9 100644 (file)
@@ -876,7 +876,7 @@ static int bus_setup_api(Manager *m, sd_bus *bus) {
 }
 
 int bus_init_api(Manager *m) {
-        _cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
+        _cleanup_(sd_bus_close_unrefp) sd_bus *bus = NULL;
         int r;
 
         if (m->api_bus)
@@ -940,7 +940,7 @@ static int bus_setup_system(Manager *m, sd_bus *bus) {
 }
 
 int bus_init_system(Manager *m) {
-        _cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
+        _cleanup_(sd_bus_close_unrefp) sd_bus *bus = NULL;
         int r;
 
         if (m->system_bus)
index 48270b3709af628d910d997f6a5d0f9b33c698af..7a558df8983c0267f73bf6017536e86d0e38394a 100644 (file)
@@ -454,7 +454,7 @@ static int container_bus_new(Machine *m, sd_bus_error *error, sd_bus **ret) {
                 break;
 
         case MACHINE_CONTAINER: {
-                _cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
+                _cleanup_(sd_bus_close_unrefp) sd_bus *bus = NULL;
                 char *address;
 
                 r = sd_bus_new(&bus);
index 976643e4ce0a4df3ec513c6d0707192059dcd7c7..cbcf698e965f5f2db8141759f34d3c0c9ecd779e 100644 (file)
@@ -559,7 +559,7 @@ int bus_check_peercred(sd_bus *c) {
 }
 
 int bus_connect_system_systemd(sd_bus **_bus) {
-        _cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
+        _cleanup_(sd_bus_close_unrefp) sd_bus *bus = NULL;
         int r;
 
         assert(_bus);
@@ -592,7 +592,7 @@ int bus_connect_system_systemd(sd_bus **_bus) {
 }
 
 int bus_connect_user_systemd(sd_bus **_bus) {
-        _cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
+        _cleanup_(sd_bus_close_unrefp) sd_bus *bus = NULL;
         _cleanup_free_ char *ee = NULL;
         const char *e;
         int r;
@@ -1279,7 +1279,7 @@ int bus_map_all_properties(
 }
 
 int bus_connect_transport(BusTransport transport, const char *host, bool user, sd_bus **ret) {
-        _cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
+        _cleanup_(sd_bus_close_unrefp) sd_bus *bus = NULL;
         int r;
 
         assert(transport >= 0);
@@ -1666,7 +1666,7 @@ int bus_track_add_name_many(sd_bus_track *t, char **l) {
 }
 
 int bus_open_system_watch_bind_with_description(sd_bus **ret, const char *description) {
-        _cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
+        _cleanup_(sd_bus_close_unrefp) sd_bus *bus = NULL;
         const char *e;
         int r;