|
|
7e7c9f |
From 24622692a67b59e943afc1d309da696e48bf6a54 Mon Sep 17 00:00:00 2001
|
|
|
f4d4e0 |
From: Lennart Poettering <lennart@poettering.net>
|
|
|
f4d4e0 |
Date: Fri, 15 Dec 2017 22:24:16 +0100
|
|
|
f4d4e0 |
Subject: [PATCH] sd-bus: when attached to an sd-event loop, disconnect on
|
|
|
f4d4e0 |
processing errors
|
|
|
f4d4e0 |
|
|
|
f4d4e0 |
If we can't process the bus for some reason we shouldn't just disable
|
|
|
f4d4e0 |
the event source, but log something and give up on the connection. Hence
|
|
|
f4d4e0 |
do that, and disconnect.
|
|
|
f4d4e0 |
|
|
|
f4d4e0 |
(cherry-picked from commit 5ae37ad833583e6c1c7765767b7f8360afca3b07)
|
|
|
f4d4e0 |
|
|
|
7e7c9f |
Resolves: #1769928
|
|
|
f4d4e0 |
---
|
|
|
f4d4e0 |
src/libsystemd/sd-bus/sd-bus.c | 45 +++++++++++++++++++++-------------
|
|
|
f4d4e0 |
1 file changed, 28 insertions(+), 17 deletions(-)
|
|
|
f4d4e0 |
|
|
|
f4d4e0 |
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
|
|
|
f4d4e0 |
index 44ed2c7497..2c8cc66367 100644
|
|
|
f4d4e0 |
--- a/src/libsystemd/sd-bus/sd-bus.c
|
|
|
f4d4e0 |
+++ b/src/libsystemd/sd-bus/sd-bus.c
|
|
|
f4d4e0 |
@@ -3037,8 +3037,10 @@ static int io_callback(sd_event_source *s, int fd, uint32_t revents, void *userd
|
|
|
f4d4e0 |
assert(bus);
|
|
|
f4d4e0 |
|
|
|
f4d4e0 |
r = sd_bus_process(bus, NULL);
|
|
|
f4d4e0 |
- if (r < 0)
|
|
|
f4d4e0 |
- return r;
|
|
|
f4d4e0 |
+ if (r < 0) {
|
|
|
f4d4e0 |
+ log_debug_errno(r, "Processing of bus failed, closing down: %m");
|
|
|
f4d4e0 |
+ bus_enter_closing(bus);
|
|
|
f4d4e0 |
+ }
|
|
|
f4d4e0 |
|
|
|
f4d4e0 |
return 1;
|
|
|
f4d4e0 |
}
|
|
|
f4d4e0 |
@@ -3050,8 +3052,10 @@ static int time_callback(sd_event_source *s, uint64_t usec, void *userdata) {
|
|
|
f4d4e0 |
assert(bus);
|
|
|
f4d4e0 |
|
|
|
f4d4e0 |
r = sd_bus_process(bus, NULL);
|
|
|
f4d4e0 |
- if (r < 0)
|
|
|
f4d4e0 |
- return r;
|
|
|
f4d4e0 |
+ if (r < 0) {
|
|
|
f4d4e0 |
+ log_debug_errno(r, "Processing of bus failed, closing down: %m");
|
|
|
f4d4e0 |
+ bus_enter_closing(bus);
|
|
|
f4d4e0 |
+ }
|
|
|
f4d4e0 |
|
|
|
f4d4e0 |
return 1;
|
|
|
f4d4e0 |
}
|
|
|
f4d4e0 |
@@ -3065,38 +3069,45 @@ static int prepare_callback(sd_event_source *s, void *userdata) {
|
|
|
f4d4e0 |
assert(bus);
|
|
|
f4d4e0 |
|
|
|
f4d4e0 |
e = sd_bus_get_events(bus);
|
|
|
f4d4e0 |
- if (e < 0)
|
|
|
f4d4e0 |
- return e;
|
|
|
f4d4e0 |
+ if (e < 0) {
|
|
|
f4d4e0 |
+ r = e;
|
|
|
f4d4e0 |
+ goto fail;
|
|
|
f4d4e0 |
+ }
|
|
|
f4d4e0 |
|
|
|
f4d4e0 |
if (bus->output_fd != bus->input_fd) {
|
|
|
f4d4e0 |
|
|
|
f4d4e0 |
r = sd_event_source_set_io_events(bus->input_io_event_source, e & POLLIN);
|
|
|
f4d4e0 |
if (r < 0)
|
|
|
f4d4e0 |
- return r;
|
|
|
f4d4e0 |
+ goto fail;
|
|
|
f4d4e0 |
|
|
|
f4d4e0 |
r = sd_event_source_set_io_events(bus->output_io_event_source, e & POLLOUT);
|
|
|
f4d4e0 |
- if (r < 0)
|
|
|
f4d4e0 |
- return r;
|
|
|
f4d4e0 |
- } else {
|
|
|
f4d4e0 |
+ } else
|
|
|
f4d4e0 |
r = sd_event_source_set_io_events(bus->input_io_event_source, e);
|
|
|
f4d4e0 |
- if (r < 0)
|
|
|
f4d4e0 |
- return r;
|
|
|
f4d4e0 |
- }
|
|
|
f4d4e0 |
+ if (r < 0)
|
|
|
f4d4e0 |
+ goto fail;
|
|
|
f4d4e0 |
|
|
|
f4d4e0 |
r = sd_bus_get_timeout(bus, &until);
|
|
|
f4d4e0 |
if (r < 0)
|
|
|
f4d4e0 |
- return r;
|
|
|
f4d4e0 |
+ goto fail;
|
|
|
f4d4e0 |
if (r > 0) {
|
|
|
f4d4e0 |
int j;
|
|
|
f4d4e0 |
|
|
|
f4d4e0 |
j = sd_event_source_set_time(bus->time_event_source, until);
|
|
|
f4d4e0 |
- if (j < 0)
|
|
|
f4d4e0 |
- return j;
|
|
|
f4d4e0 |
+ if (j < 0) {
|
|
|
f4d4e0 |
+ r = j;
|
|
|
f4d4e0 |
+ goto fail;
|
|
|
f4d4e0 |
+ }
|
|
|
f4d4e0 |
}
|
|
|
f4d4e0 |
|
|
|
f4d4e0 |
r = sd_event_source_set_enabled(bus->time_event_source, r > 0);
|
|
|
f4d4e0 |
if (r < 0)
|
|
|
f4d4e0 |
- return r;
|
|
|
f4d4e0 |
+ goto fail;
|
|
|
f4d4e0 |
+
|
|
|
f4d4e0 |
+ return 1;
|
|
|
f4d4e0 |
+
|
|
|
f4d4e0 |
+fail:
|
|
|
f4d4e0 |
+ log_debug_errno(r, "Preparing of bus events failed, closing down: %m");
|
|
|
f4d4e0 |
+ bus_enter_closing(bus);
|
|
|
f4d4e0 |
|
|
|
f4d4e0 |
return 1;
|
|
|
f4d4e0 |
}
|