From fa68ce444fb28892e5d98bcc7a1243ba5824fe13 Mon Sep 17 00:00:00 2001 From: Marek Rusinowski Date: Sun, 7 Feb 2016 19:30:31 +0100 Subject: [PATCH] Improved handling of dbus disconnection --- dbus/DBusConnection.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dbus/DBusConnection.cc b/dbus/DBusConnection.cc index 33ba6e773..4ce52cefc 100644 --- a/dbus/DBusConnection.cc +++ b/dbus/DBusConnection.cc @@ -41,6 +41,7 @@ namespace DBus dbus_error_free(&err); throw FatalException(); } + dbus_connection_set_exit_on_disconnect(conn, false); if (!conn) { @@ -146,7 +147,14 @@ namespace DBus Connection::pop_message() { boost::lock_guard lock(mutex); - return dbus_connection_pop_message(conn); + DBusMessage* tmp = dbus_connection_pop_message(conn); + if (tmp && + strcmp(dbus_message_get_interface(tmp), DBUS_INTERFACE_LOCAL) == 0 && + strcmp(dbus_message_get_member(tmp), "Disconnected") == 0) + { + throw FatalException(); + } + return tmp; }