Kaydet (Commit) dc3ff192 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Avoid further unwanted interference of DbusIpcThread::execute/close

...after 38081c08 "Avoid race between
DbusIpcThread::close and DbusIpcThread::execute"

Change-Id: I812f53525f4c2c051781321dac7096e3bf0d7054
üst 0ce75cde
...@@ -449,6 +449,7 @@ private: ...@@ -449,6 +449,7 @@ private:
void close() override; void close() override;
DbusConnectionHolder connection_; DbusConnectionHolder connection_;
osl::Condition closeDone_;
}; };
RequestHandler::Status DbusIpcThread::enable(rtl::Reference<IpcThread> * thread) RequestHandler::Status DbusIpcThread::enable(rtl::Reference<IpcThread> * thread)
...@@ -569,6 +570,19 @@ void DbusIpcThread::execute() ...@@ -569,6 +570,19 @@ void DbusIpcThread::execute()
if (dbus_message_is_method_call( if (dbus_message_is_method_call(
msg.message, "org.libreoffice.LibreOfficeIpcIfc0", "Close")) msg.message, "org.libreoffice.LibreOfficeIpcIfc0", "Close"))
{ {
DbusMessageHolder repl(dbus_message_new_method_return(msg.message));
if (repl.message == nullptr) {
SAL_WARN(
"desktop.app", "dbus_message_new_method_return failed");
} else {
dbus_uint32_t serial = 0;
if (!dbus_connection_send(
connection_.connection, repl.message, &serial)) {
SAL_WARN("desktop.app", "dbus_connection_send failed");
} else {
dbus_connection_flush(connection_.connection);
}
}
break; break;
} }
if (!dbus_message_is_method_call( if (!dbus_message_is_method_call(
...@@ -612,6 +626,7 @@ void DbusIpcThread::execute() ...@@ -612,6 +626,7 @@ void DbusIpcThread::execute()
} }
dbus_connection_flush(connection_.connection); dbus_connection_flush(connection_.connection);
} }
closeDone_.wait();
DBusError e; DBusError e;
dbus_error_init(&e); dbus_error_init(&e);
int n = dbus_bus_release_name( int n = dbus_bus_release_name(
...@@ -639,13 +654,14 @@ void DbusIpcThread::execute() ...@@ -639,13 +654,14 @@ void DbusIpcThread::execute()
} }
void DbusIpcThread::close() { void DbusIpcThread::close() {
{
assert(connection_.connection != nullptr); assert(connection_.connection != nullptr);
DBusError e; DBusError e;
dbus_error_init(&e); dbus_error_init(&e);
// Let DbusIpcThread::execute return from dbus_connection_read_write; for // Let DbusIpcThread::execute return from dbus_connection_read_write;
// now, just abort on failure (the process would otherwise block, with // for now, just abort on failure (the process would otherwise block,
// DbusIpcThread::execute hanging in dbus_connection_read_write); this // with DbusIpcThread::execute hanging in dbus_connection_read_write);
// apparently needs a more DBus-y design anyway: // this apparently needs a more DBus-y design anyway:
DbusConnectionHolder con(dbus_bus_get_private(DBUS_BUS_SESSION, &e)); DbusConnectionHolder con(dbus_bus_get_private(DBUS_BUS_SESSION, &e));
assert((con.connection == nullptr) == bool(dbus_error_is_set(&e))); assert((con.connection == nullptr) == bool(dbus_error_is_set(&e)));
if (con.connection == nullptr) { if (con.connection == nullptr) {
...@@ -665,11 +681,19 @@ void DbusIpcThread::close() { ...@@ -665,11 +681,19 @@ void DbusIpcThread::close() {
SAL_WARN("desktop.app", "dbus_message_new_method_call failed"); SAL_WARN("desktop.app", "dbus_message_new_method_call failed");
std::abort(); std::abort();
} }
if (!dbus_connection_send(con.connection, msg.message, nullptr)) { DbusMessageHolder repl(
SAL_WARN("desktop.app", "dbus_connection_send failed"); dbus_connection_send_with_reply_and_block(
std::abort(); con.connection, msg.message, 0x7FFFFFFF, &e));
assert((repl.message == nullptr) == bool(dbus_error_is_set(&e)));
if (repl.message == nullptr) {
SAL_INFO(
"desktop.app",
"dbus_connection_send_with_reply_and_block failed with: "
<< e.name << ": " << e.message);
dbus_error_free(&e);
}
} }
dbus_connection_flush(con.connection); closeDone_.set();
} }
#endif #endif
......
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