Commit 39d6816a authored by Max Kellermann's avatar Max Kellermann

neighbor/upnp: roll back changes if DoOpen() fails

parent 6517b2d2
......@@ -113,15 +113,19 @@ UdisksNeighborExplorer::DoOpen()
auto &connection = GetConnection();
/* this ugly try/catch cascade is only here because this
method has no RAII for this method - TODO: improve this */
try {
Error error;
dbus_bus_add_match(connection, udisks_neighbor_match, error);
error.CheckThrow("DBus AddMatch error");
try {
dbus_connection_add_filter(connection,
HandleMessage, this,
nullptr);
try {
auto msg = Message::NewMethodCall(UDISKS2_INTERFACE,
UDISKS2_PATH,
DBUS_OM_INTERFACE,
......@@ -130,6 +134,17 @@ UdisksNeighborExplorer::DoOpen()
std::bind(&UdisksNeighborExplorer::OnListNotify,
this, std::placeholders::_1));
} catch (...) {
dbus_connection_remove_filter(connection,
HandleMessage,
this);
throw;
}
} catch (...) {
dbus_bus_remove_match(connection,
udisks_neighbor_match, nullptr);
throw;
}
} catch (...) {
dbus_glue.Destruct();
throw;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment