summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cgroups-agent/cgroups-agent.c2
-rw-r--r--src/libelogind/sd-bus/bus-util.h11
-rw-r--r--src/libelogind/sd-bus/busctl.c2
-rw-r--r--src/libelogind/sd-bus/sd-bus.c11
-rw-r--r--src/libelogind/sd-bus/test-bus-chat.c4
-rw-r--r--src/libelogind/sd-bus/test-bus-gvariant.c2
-rw-r--r--src/libelogind/sd-bus/test-bus-match.c2
-rw-r--r--src/libsystemd/libsystemd.sym1
-rw-r--r--src/login/inhibit.c2
-rw-r--r--src/login/loginctl.c2
-rw-r--r--src/login/pam_elogind.c4
-rw-r--r--src/systemd/sd-bus.h1
12 files changed, 25 insertions, 19 deletions
diff --git a/src/cgroups-agent/cgroups-agent.c b/src/cgroups-agent/cgroups-agent.c
index 3be4cff80..cca5cec3d 100644
--- a/src/cgroups-agent/cgroups-agent.c
+++ b/src/cgroups-agent/cgroups-agent.c
@@ -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) {
diff --git a/src/libelogind/sd-bus/bus-util.h b/src/libelogind/sd-bus/bus-util.h
index 6ab69963c..75b842891 100644
--- a/src/libelogind/sd-bus/bus-util.h
+++ b/src/libelogind/sd-bus/bus-util.h
@@ -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)
diff --git a/src/libelogind/sd-bus/busctl.c b/src/libelogind/sd-bus/busctl.c
index 39caa4e7d..704939c6c 100644
--- a/src/libelogind/sd-bus/busctl.c
+++ b/src/libelogind/sd-bus/busctl.c
@@ -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();
diff --git a/src/libelogind/sd-bus/sd-bus.c b/src/libelogind/sd-bus/sd-bus.c
index c57635076..87263b74f 100644
--- a/src/libelogind/sd-bus/sd-bus.c
+++ b/src/libelogind/sd-bus/sd-bus.c
@@ -1425,6 +1425,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);
diff --git a/src/libelogind/sd-bus/test-bus-chat.c b/src/libelogind/sd-bus/test-bus-chat.c
index 046e99900..754335b5e 100644
--- a/src/libelogind/sd-bus/test-bus-chat.c
+++ b/src/libelogind/sd-bus/test-bus-chat.c
@@ -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;
diff --git a/src/libelogind/sd-bus/test-bus-gvariant.c b/src/libelogind/sd-bus/test-bus-gvariant.c
index 22ea00c2f..9b7dd2e49 100644
--- a/src/libelogind/sd-bus/test-bus-gvariant.c
+++ b/src/libelogind/sd-bus/test-bus-gvariant.c
@@ -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;
diff --git a/src/libelogind/sd-bus/test-bus-match.c b/src/libelogind/sd-bus/test-bus-match.c
index a1687b1c7..83cb5c62c 100644
--- a/src/libelogind/sd-bus/test-bus-match.c
+++ b/src/libelogind/sd-bus/test-bus-match.c
@@ -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;
diff --git a/src/libsystemd/libsystemd.sym b/src/libsystemd/libsystemd.sym
index 97005dbac..7bf1d66dd 100644
--- a/src/libsystemd/libsystemd.sym
+++ b/src/libsystemd/libsystemd.sym
@@ -465,4 +465,5 @@ global:
/* sd-bus */
sd_bus_emit_object_added;
sd_bus_emit_object_removed;
+ sd_bus_flush_close_unref;
} LIBSYSTEMD_221;
diff --git a/src/login/inhibit.c b/src/login/inhibit.c
index 0e5dce592..c53ea8add 100644
--- a/src/login/inhibit.c
+++ b/src/login/inhibit.c
@@ -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();
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
index a47563b50..31400d962 100644
--- a/src/login/loginctl.c
+++ b/src/login/loginctl.c
@@ -1656,7 +1656,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, "");
diff --git a/src/login/pam_elogind.c b/src/login/pam_elogind.c
index 6f941f836..f75b8ac2c 100644
--- a/src/login/pam_elogind.c
+++ b/src/login/pam_elogind.c
@@ -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;
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index 57e46ced8..f34893171 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -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);