D-Bus callbacks: ignore errors while sending failure reply

When the parent has died, sending a reply to its method call will
fail. This must not kill the D-Bus helper. Currently only the failure
reply is secured that way, reasoning that if something already went
wrong, further errors can be ignored.

Sending a positive result might need the same treatment.
This commit is contained in:
Patrick Ohly 2012-05-08 13:26:38 +02:00
parent 8f753af2eb
commit bcc130a479
1 changed files with 8 additions and 1 deletions

View File

@ -38,7 +38,14 @@ uint32_t dbusErrorCallback(const boost::shared_ptr<GDBusCXX::Result> &result)
// let D-Bus parent log the error
std::string explanation;
uint32_t error = Exception::handle(explanation, HANDLE_EXCEPTION_NO_ERROR);
result->failed(GDBusCXX::dbus_error(SessionCommon::SERVER_IFACE, explanation));
try {
result->failed(GDBusCXX::dbus_error(SessionCommon::SERVER_IFACE, explanation));
} catch (...) {
// Ignore failures while sending the reply. This can
// happen when our caller dropped the connection before we
// could reply.
Exception::handle(HANDLE_EXCEPTION_NO_ERROR);
}
return error;
}
// keep compiler happy