SHA256
1
0
forked from pool/systemd
systemd/avoid-leaking-socket-descriptors.patch

40 lines
1.5 KiB
Diff
Raw Normal View History

---
src/core/dbus.c | 2 +-
src/libsystemd/sd-bus/bus-util.h | 9 +++++++++
2 files changed, 10 insertions(+), 1 deletion(-)
--- 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)