From 0358b3f95d7cfdd05e7cb8394cfdb6b3b4b14ffc Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 21 Dec 2013 04:03:12 +0100 Subject: bus: properly react to Disconnected messages in bus-proxyd --- src/bus-proxyd/bus-proxyd.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c index ce2a20bb89..4145217204 100644 --- a/src/bus-proxyd/bus-proxyd.c +++ b/src/bus-proxyd/bus-proxyd.c @@ -209,11 +209,22 @@ int main(int argc, char *argv[]) { r = sd_bus_process(a, &m); if (r < 0) { - log_error("Failed to process bus a: %s", strerror(-r)); + /* treat 'connection reset by peer' as clean exit condition */ + if (r == -ECONNRESET) + r = 0; + else + log_error("Failed to process bus a: %s", strerror(-r)); + goto finish; } if (m) { + /* We officially got EOF, let's quit */ + if (sd_bus_message_is_signal(m, "org.freedesktop.DBus.Local", "Disconnected")) { + r = 0; + goto finish; + } + r = sd_bus_send(b, m, NULL); if (r < 0) { log_error("Failed to send message: %s", strerror(-r)); @@ -229,11 +240,19 @@ int main(int argc, char *argv[]) { /* treat 'connection reset by peer' as clean exit condition */ if (r == -ECONNRESET) r = 0; + else + log_error("Failed to process bus b: %s", strerror(-r)); goto finish; } if (m) { + /* We officially got EOF, let's quit */ + if (sd_bus_message_is_signal(m, "org.freedesktop.DBus.Local", "Disconnected")) { + r = 0; + goto finish; + } + r = sd_bus_send(a, m, NULL); if (r < 0) { log_error("Failed to send message: %s", strerror(-r)); @@ -309,5 +328,8 @@ int main(int argc, char *argv[]) { r = 0; finish: + sd_bus_flush(a); + sd_bus_flush(b); + return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; } -- cgit v1.2.3-54-g00ecf