]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-bus: introduce new sd_bus_flush_close_unref() call 485/head
authorLennart Poettering <lennart@poettering.net>
Fri, 3 Jul 2015 17:49:03 +0000 (19:49 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 3 Jul 2015 17:49:03 +0000 (19:49 +0200)
sd_bus_flush_close_unref() is a call that simply combines sd_bus_flush()
(which writes all unwritten messages out) + sd_bus_close() (which
terminates the connection, releasing all unread messages) +
sd_bus_unref() (which frees the connection).

The combination of this call is used pretty frequently in systemd tools
right before exiting, and should also be relevant for most external
clients, and is hence useful to cover in a call of its own.

Previously the combination of the three calls was already done in the
_cleanup_bus_close_unref_ macro, but this was only available internally.

Also see #327

31 files changed:
src/analyze/analyze.c
src/bus-proxyd/proxy.c
src/cgls/cgls.c
src/cgroups-agent/cgroups-agent.c
src/fsck/fsck.c
src/hostname/hostnamectl.c
src/hostname/hostnamed.c
src/import/importd.c
src/journal/journalctl.c
src/libsystemd/libsystemd.sym
src/libsystemd/sd-bus/busctl.c
src/libsystemd/sd-bus/sd-bus.c
src/libsystemd/sd-bus/test-bus-chat.c
src/libsystemd/sd-bus/test-bus-gvariant.c
src/libsystemd/sd-bus/test-bus-match.c
src/locale/localectl.c
src/locale/localed.c
src/login/inhibit.c
src/login/loginctl.c
src/login/pam_systemd.c
src/machine/machinectl.c
src/nspawn/nspawn.c
src/nss-mymachines/nss-mymachines.c
src/nss-resolve/nss-resolve.c
src/resolve-host/resolve-host.c
src/run/run.c
src/shared/bus-util.h
src/systemctl/systemctl.c
src/systemd/sd-bus.h
src/timedate/timedatectl.c
src/timedate/timedated.c

index 9583458f726e0784e286ec269c410cd23e0ddecb..c0863e4167d063cfbfd0f84ab408c84da41180a7 100644 (file)
@@ -1331,7 +1331,7 @@ int main(int argc, char *argv[]) {
                                  arg_user ? MANAGER_USER : MANAGER_SYSTEM,
                                  arg_man);
         else {
-                _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+                _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
 
                 r = bus_open_transport_systemd(arg_transport, arg_host, arg_user, &bus);
                 if (r < 0) {
index 1dc55171e7b81b0a60f3fb2f89513e07ace3dce8..c0055d3788562999eb2d818c9322a8303ae2df8d 100644 (file)
@@ -45,7 +45,7 @@
 #include "formats-util.h"
 
 static int proxy_create_destination(Proxy *p, const char *destination, const char *local_sec, bool negotiate_fds) {
-        _cleanup_bus_close_unref_ sd_bus *b = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *b = NULL;
         int r;
 
         r = sd_bus_new(&b);
@@ -101,7 +101,7 @@ static int proxy_create_destination(Proxy *p, const char *destination, const cha
 }
 
 static int proxy_create_local(Proxy *p, int in_fd, int out_fd, bool negotiate_fds) {
-        _cleanup_bus_close_unref_ sd_bus *b = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *b = NULL;
         sd_id128_t server_id;
         int r;
 
@@ -238,8 +238,8 @@ Proxy *proxy_free(Proxy *p) {
         if (!p)
                 return NULL;
 
-        sd_bus_close_unrefp(&p->local_bus);
-        sd_bus_close_unrefp(&p->destination_bus);
+        sd_bus_flush_close_unref(p->local_bus);
+        sd_bus_flush_close_unref(p->destination_bus);
         set_free_free(p->owned_names);
         free(p);
 
index c6f5485716962fc08390880508eb4e2e3c5e922e..46a444340a22a6714f46bbf45a9c2f8689de4f2e 100644 (file)
@@ -127,7 +127,7 @@ int main(int argc, char *argv[]) {
         int r = 0, retval = EXIT_FAILURE;
         int output_flags;
         _cleanup_free_ char *root = NULL;
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
 
         log_parse_environment();
         log_open();
index 529e8430303207458f15f9074ac9492b4fd1d808..612bc8fdec7ad9f8ca7b8a32ebd27a804108a76e 100644 (file)
@@ -26,7 +26,7 @@
 #include "bus-util.h"
 
 int main(int argc, char *argv[]) {
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         int r;
 
         if (argc != 2) {
index 30254b6680c22e7f27257365e3bbadafc6f24e59..bd3051f30dcd0e9dc417b685f0063a45d832e334 100644 (file)
@@ -62,7 +62,7 @@ static const char *arg_repair = "-a";
 
 static void start_target(const char *target) {
         _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         int r;
 
         assert(target);
index 69ecd61f6068f00f78bd2bfe1cca9bd10aba116e..c996fc04a08aefcba6a61c7697f7df33e99cb080 100644 (file)
@@ -509,7 +509,7 @@ static int hostnamectl_main(sd_bus *bus, int argc, char *argv[]) {
 }
 
 int main(int argc, char *argv[]) {
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         int r;
 
         setlocale(LC_ALL, "");
index 7ff3a4e224142a08467067e804d0d0794273ca33..e52b872a8c7bc9f455932e91145ffffad2e7c99d 100644 (file)
@@ -663,7 +663,7 @@ static const sd_bus_vtable hostname_vtable[] = {
 };
 
 static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         int r;
 
         assert(c);
@@ -695,7 +695,7 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
 int main(int argc, char *argv[]) {
         Context context = {};
         _cleanup_event_unref_ sd_event *event = NULL;
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         int r;
 
         log_set_target(LOG_TARGET_AUTO);
index 03aede6016c00dc4ef082ed2a96768b2dcac27a8..dd314f5b0024ee139ee231d305034ade8186b482 100644 (file)
@@ -551,8 +551,7 @@ static Manager *manager_unref(Manager *m) {
 
         bus_verify_polkit_async_registry_free(m->polkit_registry);
 
-        sd_bus_close(m->bus);
-        sd_bus_unref(m->bus);
+        m->bus = sd_bus_flush_close_unref(m->bus);
         sd_event_unref(m->event);
 
         free(m);
index 76ec0827e7211c057fb15bdc85cab4d898cf4276..2d6ecfb75084fe2418b4164a3d6864d6185a3c9d 100644 (file)
@@ -1719,7 +1719,7 @@ static int access_check(sd_journal *j) {
 
 static int flush_to_var(void) {
         _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         _cleanup_close_ int watch_fd = -1;
         int r;
 
index 97005dbac38a23ed047475f35ed00e4567e51b32..7bf1d66dde1696df669e9c78b49d7789ec877d5d 100644 (file)
@@ -465,4 +465,5 @@ global:
         /* sd-bus */
         sd_bus_emit_object_added;
         sd_bus_emit_object_removed;
+        sd_bus_flush_close_unref;
 } LIBSYSTEMD_221;
index 39caa4e7d6f95a144fe9c6e8577bdf49ae121b6f..704939c6cfebef87e6d84b53b9bc0f65c645326a 100644 (file)
@@ -1973,7 +1973,7 @@ static int busctl_main(sd_bus *bus, int argc, char *argv[]) {
 }
 
 int main(int argc, char *argv[]) {
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         int r;
 
         log_parse_environment();
index 5dd64687074a1fc8878a50feb4ac95cc4171caab..0ca225c61759dfd67656da288dda1b7dcc9e4571 100644 (file)
@@ -1428,6 +1428,17 @@ _public_ void sd_bus_close(sd_bus *bus) {
          * ioctl on the fd when they are freed. */
 }
 
+_public_ sd_bus* sd_bus_flush_close_unref(sd_bus *bus) {
+
+        if (!bus)
+                return NULL;
+
+        sd_bus_flush(bus);
+        sd_bus_close(bus);
+
+        return sd_bus_unref(bus);
+}
+
 static void bus_enter_closing(sd_bus *bus) {
         assert(bus);
 
index 046e999008283941f1087f37f2fc5466f0a66a70..754335b5e7d98afbe8be0406710f6a0537d64f70 100644 (file)
@@ -262,7 +262,7 @@ fail:
 
 static void* client1(void*p) {
         _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
         const char *hello;
         int r;
@@ -361,7 +361,7 @@ static int quit_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_er
 
 static void* client2(void*p) {
         _cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
         bool quit = false;
         const char *mid;
index 22ea00c2fbc8fec49ec7891db586b02dac0c7cf6..9b7dd2e49941161d8d667551fb01b1c15f9728ea 100644 (file)
@@ -132,7 +132,7 @@ static void test_bus_gvariant_get_alignment(void) {
 
 static void test_marshal(void) {
         _cleanup_bus_message_unref_ sd_bus_message *m = NULL, *n = NULL;
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         _cleanup_free_ void *blob;
         size_t sz;
         int r;
index a1687b1c7bb81f835b3fbfec61649f003837abac..83cb5c62c2c4fb88180ecedb7d93ae0cf61ac9e3 100644 (file)
@@ -92,7 +92,7 @@ int main(int argc, char *argv[]) {
         };
 
         _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         enum bus_match_node_type i;
         sd_bus_slot slots[19];
         int r;
index 601839d5dc1e77e7483571f241b7753c982abc7b..3616f4af1f1831fc6ed0b1e22f526d92f2654dc2 100644 (file)
@@ -667,7 +667,7 @@ static int localectl_main(sd_bus *bus, int argc, char *argv[]) {
 }
 
 int main(int argc, char*argv[]) {
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         int r;
 
         setlocale(LC_ALL, "");
index 0e59350e98d5db432870de5bea479b6fbfb51e22..88756542fdb1d90b76f84c5f2e01d2019a4926b4 100644 (file)
@@ -1240,7 +1240,7 @@ static const sd_bus_vtable locale_vtable[] = {
 };
 
 static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         int r;
 
         assert(c);
@@ -1272,7 +1272,7 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
 int main(int argc, char *argv[]) {
         _cleanup_(context_free) Context context = {};
         _cleanup_event_unref_ sd_event *event = NULL;
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         int r;
 
         log_set_target(LOG_TARGET_AUTO);
index 0e5dce59258c47ae797a668af8dcc3d57be5ee6d..c53ea8add7c6c1efe2da0812d1117362ce6d1a28 100644 (file)
@@ -223,7 +223,7 @@ static int parse_argv(int argc, char *argv[]) {
 
 int main(int argc, char *argv[]) {
         _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         int r;
 
         log_parse_environment();
index 06208bc4b32e5d7eba0d2435a4378b5d992e4134..9709eca9bdc985dc6634557f493c02feb8536e68 100644 (file)
@@ -1389,7 +1389,7 @@ static int loginctl_main(int argc, char *argv[], sd_bus *bus) {
 }
 
 int main(int argc, char *argv[]) {
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         int r;
 
         setlocale(LC_ALL, "");
index dd192b90ce0b64a19046f6026488e93de11ddcf2..2f390237dc2bfe7d0d34c23673f78200240ef3a1 100644 (file)
@@ -213,7 +213,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
                 *seat = NULL,
                 *type = NULL, *class = NULL,
                 *class_pam = NULL, *type_pam = NULL, *cvtnr = NULL, *desktop = NULL;
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         int session_fd = -1, existing, r;
         bool debug = false, remote;
         struct passwd *pw;
@@ -496,7 +496,7 @@ _public_ PAM_EXTERN int pam_sm_close_session(
                 int argc, const char **argv) {
 
         _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         const void *existing = NULL;
         const char *id;
         int r;
index 7938aa4dbeb3a1f0b5eda79e4c91d6728e12ddbf..7cb6ce77ac927f64480cb562f4f0d6d47314893a 100644 (file)
@@ -2572,7 +2572,7 @@ static int machinectl_main(int argc, char *argv[], sd_bus *bus) {
 }
 
 int main(int argc, char*argv[]) {
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         int r;
 
         setlocale(LC_ALL, "");
index 7fa098bea8d111a6de8467b910b9227f28ed7920..4fa88c9e24d0504663f509c9187b9c6b2554e103 100644 (file)
@@ -2273,7 +2273,7 @@ static int drop_capabilities(void) {
 
 static int register_machine(pid_t pid, int local_ifindex) {
         _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         int r;
 
         if (!arg_register)
@@ -2430,7 +2430,7 @@ static int register_machine(pid_t pid, int local_ifindex) {
 static int terminate_machine(pid_t pid) {
         _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
         _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         const char *path;
         int r;
 
index 9476ad1694f2be8d52a6613e46692786c5541b6b..f712033e6c8fec5b632416820449fec78279d8eb 100644 (file)
@@ -79,7 +79,7 @@ enum nss_status _nss_mymachines_gethostbyname4_r(
 
         struct gaih_addrtuple *r_tuple, *r_tuple_first = NULL;
         _cleanup_bus_message_unref_ sd_bus_message* reply = NULL;
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         _cleanup_free_ int *ifindices = NULL;
         _cleanup_free_ char *class = NULL;
         size_t l, ms, idx;
@@ -228,7 +228,7 @@ enum nss_status _nss_mymachines_gethostbyname3_r(
                 char **canonp) {
 
         _cleanup_bus_message_unref_ sd_bus_message* reply = NULL;
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         _cleanup_free_ char *class = NULL;
         unsigned c = 0, i = 0;
         char *r_name, *r_aliases, *r_addr, *r_addr_list;
index 8f181a6c72e072315a1c042f8b4d7c82791961b6..da22f98eba8f2062d00c83e0014d4b163d4583db 100644 (file)
@@ -122,7 +122,7 @@ enum nss_status _nss_resolve_gethostbyname4_r(
         _cleanup_bus_message_unref_ sd_bus_message *req = NULL, *reply = NULL;
         _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
         struct gaih_addrtuple *r_tuple, *r_tuple_first = NULL;
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         const char *canonical = NULL;
         size_t l, ms, idx;
         char *r_name;
@@ -305,7 +305,7 @@ enum nss_status _nss_resolve_gethostbyname3_r(
         _cleanup_bus_message_unref_ sd_bus_message *req = NULL, *reply = NULL;
         _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
         char *r_name, *r_aliases, *r_addr, *r_addr_list;
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         size_t l, idx, ms, alen;
         const char *canonical;
         int c, r, i = 0, ifindex;
@@ -513,7 +513,7 @@ enum nss_status _nss_resolve_gethostbyaddr2_r(
         _cleanup_bus_message_unref_ sd_bus_message *req = NULL, *reply = NULL;
         _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
         char *r_name, *r_aliases, *r_addr, *r_addr_list;
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         unsigned c = 0, i = 0;
         size_t ms = 0, idx;
         const char *n;
index 068756cab1ea55c61cffa0a777e2de4ae4388093..f9448e3bc5fe96c9113902064ebd9f34794ca56a 100644 (file)
@@ -592,7 +592,7 @@ static int parse_argv(int argc, char *argv[]) {
 }
 
 int main(int argc, char **argv) {
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         int r;
 
         log_parse_environment();
index 99d960a664815ecfc2f5936a2904dd8d68b67336..148854a9b50ea080aacdc2ee09e5b3e747a5a06c 100644 (file)
@@ -1099,7 +1099,7 @@ static int start_transient_timer(
 }
 
 int main(int argc, char* argv[]) {
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         _cleanup_free_ char *description = NULL, *command = NULL;
         int r;
 
index d8dba584d6fc7699fc29371c0c6ccf6c616e913e..4ae216b7d9c400cab586d4e18fccb0a23260d3a3 100644 (file)
@@ -135,22 +135,15 @@ typedef struct UnitInfo {
 
 int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u);
 
-static inline void sd_bus_close_unrefp(sd_bus **bus) {
-        if (*bus) {
-                sd_bus_flush(*bus);
-                sd_bus_close(*bus);
-                sd_bus_unref(*bus);
-        }
-}
-
 DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus*, sd_bus_unref);
+DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus*, sd_bus_flush_close_unref);
 DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_slot*, sd_bus_slot_unref);
 DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_message*, sd_bus_message_unref);
 DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_creds*, sd_bus_creds_unref);
 DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_track*, sd_bus_track_unref);
 
 #define _cleanup_bus_unref_ _cleanup_(sd_bus_unrefp)
-#define _cleanup_bus_close_unref_ _cleanup_(sd_bus_close_unrefp)
+#define _cleanup_bus_flush_close_unref_ _cleanup_(sd_bus_flush_close_unrefp)
 #define _cleanup_bus_slot_unref_ _cleanup_(sd_bus_slot_unrefp)
 #define _cleanup_bus_message_unref_ _cleanup_(sd_bus_message_unrefp)
 #define _cleanup_bus_creds_unref_ _cleanup_(sd_bus_creds_unrefp)
index 538838b7fce42b49feece114df434c0391b8aa15..6db4d6587a13a312bb14324a4f2771b798fa3e62 100644 (file)
@@ -617,7 +617,7 @@ static int get_unit_list_recursive(
                         return r;
 
                 STRV_FOREACH(i, machines) {
-                        _cleanup_bus_close_unref_ sd_bus *container = NULL;
+                        _cleanup_bus_flush_close_unref_ sd_bus *container = NULL;
                         int k;
 
                         r = sd_bus_open_system_machine(&container, *i);
@@ -1709,7 +1709,7 @@ static int compare_machine_info(const void *a, const void *b) {
 }
 
 static int get_machine_properties(sd_bus *bus, struct machine_info *mi) {
-        _cleanup_bus_close_unref_ sd_bus *container = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *container = NULL;
         int r;
 
         assert(mi);
@@ -7340,7 +7340,7 @@ static int halt_main(sd_bus *bus) {
 
         if (arg_when > 0) {
                 _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
-                _cleanup_bus_close_unref_ sd_bus *b = NULL;
+                _cleanup_bus_flush_close_unref_ sd_bus *b = NULL;
                 _cleanup_free_ char *m = NULL;
 
                 if (avoid_bus()) {
@@ -7449,7 +7449,7 @@ static int runlevel_main(void) {
 }
 
 int main(int argc, char*argv[]) {
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         int r;
 
         setlocale(LC_ALL, "");
@@ -7517,7 +7517,7 @@ int main(int argc, char*argv[]) {
 
         case ACTION_CANCEL_SHUTDOWN: {
                 _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
-                _cleanup_bus_close_unref_ sd_bus *b = NULL;
+                _cleanup_bus_flush_close_unref_ sd_bus *b = NULL;
                 _cleanup_free_ char *m = NULL;
 
                 if (avoid_bus()) {
index 57e46ced8ebc0f9cf0a11045713b2ac2786a6043..f34893171fbaa8e67c113fbe21799d6562cbffee 100644 (file)
@@ -156,6 +156,7 @@ void sd_bus_close(sd_bus *bus);
 
 sd_bus *sd_bus_ref(sd_bus *bus);
 sd_bus *sd_bus_unref(sd_bus *bus);
+sd_bus *sd_bus_flush_close_unref(sd_bus *bus);
 
 int sd_bus_is_open(sd_bus *bus);
 
index 25c25952aafa7442f61371104f52da83731f6503..240578bca0fafb19ee6696b24075428594d33a27 100644 (file)
@@ -491,7 +491,7 @@ static int timedatectl_main(sd_bus *bus, int argc, char *argv[]) {
 }
 
 int main(int argc, char *argv[]) {
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         int r;
 
         setlocale(LC_ALL, "");
index 4e8ae947173db2632a57dfb1848dcbc751b22d52..21d6ee4c0c556ae9d2b418319881854bdeedc267 100644 (file)
@@ -660,7 +660,7 @@ static const sd_bus_vtable timedate_vtable[] = {
 };
 
 static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         int r;
 
         assert(c);
@@ -692,7 +692,7 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
 int main(int argc, char *argv[]) {
         Context context = {};
         _cleanup_event_unref_ sd_event *event = NULL;
-        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
         int r;
 
         log_set_target(LOG_TARGET_AUTO);