neighbor/upnp: roll back changes if DoOpen() fails
This commit is contained in:
parent
6517b2d2ac
commit
39d6816a6d
@ -113,22 +113,37 @@ UdisksNeighborExplorer::DoOpen()
|
|||||||
|
|
||||||
auto &connection = GetConnection();
|
auto &connection = GetConnection();
|
||||||
|
|
||||||
|
/* this ugly try/catch cascade is only here because this
|
||||||
|
method has no RAII for this method - TODO: improve this */
|
||||||
try {
|
try {
|
||||||
Error error;
|
Error error;
|
||||||
dbus_bus_add_match(connection, udisks_neighbor_match, error);
|
dbus_bus_add_match(connection, udisks_neighbor_match, error);
|
||||||
error.CheckThrow("DBus AddMatch error");
|
error.CheckThrow("DBus AddMatch error");
|
||||||
|
|
||||||
dbus_connection_add_filter(connection,
|
try {
|
||||||
HandleMessage, this,
|
dbus_connection_add_filter(connection,
|
||||||
nullptr);
|
HandleMessage, this,
|
||||||
|
nullptr);
|
||||||
|
|
||||||
auto msg = Message::NewMethodCall(UDISKS2_INTERFACE,
|
try {
|
||||||
UDISKS2_PATH,
|
auto msg = Message::NewMethodCall(UDISKS2_INTERFACE,
|
||||||
DBUS_OM_INTERFACE,
|
UDISKS2_PATH,
|
||||||
"GetManagedObjects");
|
DBUS_OM_INTERFACE,
|
||||||
list_request.Send(connection, *msg.Get(),
|
"GetManagedObjects");
|
||||||
std::bind(&UdisksNeighborExplorer::OnListNotify,
|
list_request.Send(connection, *msg.Get(),
|
||||||
this, std::placeholders::_1));
|
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 (...) {
|
} catch (...) {
|
||||||
dbus_glue.Destruct();
|
dbus_glue.Destruct();
|
||||||
throw;
|
throw;
|
||||||
|
Loading…
Reference in New Issue
Block a user