--- src/core/dbus.c | 2 +- src/libsystemd/sd-bus/bus-util.h | 9 +++++++++ src/login/pam-module.c | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) --- src/core/dbus.c +++ src/core/dbus.c 2014-10-17 09:52:47.227838182 +0000 @@ -639,7 +639,7 @@ static int bus_setup_disconnected_match( } static int bus_on_connection(sd_event_source *s, int fd, uint32_t revents, void *userdata) { - _cleanup_bus_unref_ sd_bus *bus = NULL; + _cleanup_bus_close_unref_ sd_bus *bus = NULL; _cleanup_close_ int nfd = -1; Manager *m = userdata; sd_id128_t id; --- src/libsystemd/sd-bus/bus-util.h +++ src/libsystemd/sd-bus/bus-util.h 2014-10-17 09:51:34.368337493 +0000 @@ -137,11 +137,20 @@ 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_message*, sd_bus_message_unref); DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_creds*, sd_bus_creds_unref); #define _cleanup_bus_unref_ _cleanup_(sd_bus_unrefp) +#define _cleanup_bus_close_unref_ _cleanup_(sd_bus_close_unrefp) #define _cleanup_bus_message_unref_ _cleanup_(sd_bus_message_unrefp) #define _cleanup_bus_creds_unref_ _cleanup_(sd_bus_creds_unrefp) #define _cleanup_bus_error_free_ _cleanup_(sd_bus_error_free) --- src/login/pam-module.c +++ src/login/pam-module.c 2014-10-21 10:48:20.129001984 +0000 @@ -213,7 +213,7 @@ _public_ PAM_EXTERN int pam_sm_open_sess *seat = NULL, *type = NULL, *class = NULL, *class_pam = NULL, *type_pam = NULL, *cvtnr = NULL, *desktop = NULL; - _cleanup_bus_unref_ sd_bus *bus = NULL; + _cleanup_bus_close_unref_ sd_bus *bus = NULL; int session_fd = -1, existing, r; bool debug = false, remote; struct passwd *pw; @@ -517,7 +517,7 @@ _public_ PAM_EXTERN int pam_sm_close_ses int argc, const char **argv) { _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; - _cleanup_bus_unref_ sd_bus *bus = NULL; + _cleanup_bus_close_unref_ sd_bus *bus = NULL; const void *existing = NULL; const char *id; int r;