summaryrefslogtreecommitdiff
path: root/src/bus-proxyd
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-21 04:03:12 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-21 04:03:12 +0100
commit0358b3f95d7cfdd05e7cb8394cfdb6b3b4b14ffc (patch)
tree2749a7af0265eff102e8c4c16e00fce5fc58ec91 /src/bus-proxyd
parentba7689164c0f81ad23861b486514c86ec908ffee (diff)
bus: properly react to Disconnected messages in bus-proxyd
Diffstat (limited to 'src/bus-proxyd')
-rw-r--r--src/bus-proxyd/bus-proxyd.c24
1 files changed, 23 insertions, 1 deletions
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;
}