gdbus: fix deadlock on message cancel/timeout

The gdbus GTask port introduced a deadlock because some code had been
using g_simple_async_result_complete_in_idle() to ensure that the
callback didn't run until after a mutex was unlocked, but in the gtask
version, the callback was being run immediately. Fix it to drop the
mutex before calling g_task_return*(). Also, tweak
tests/gdbus-connection to test this.

https://bugzilla.gnome.org/show_bug.cgi?id=747349
This commit is contained in:
Dan Winship
2015-04-06 10:09:04 -04:00
parent 95d300eac5
commit 7e8d4145af
2 changed files with 45 additions and 32 deletions

View File

@@ -291,6 +291,9 @@ msg_cb_expect_error_disconnected (GDBusConnection *connection,
GError *error;
GVariant *result;
/* Make sure gdbusconnection isn't holding @connection's lock. (#747349) */
g_dbus_connection_get_last_serial (connection);
error = NULL;
result = g_dbus_connection_call_finish (connection,
res,
@@ -311,6 +314,9 @@ msg_cb_expect_error_unknown_method (GDBusConnection *connection,
GError *error;
GVariant *result;
/* Make sure gdbusconnection isn't holding @connection's lock. (#747349) */
g_dbus_connection_get_last_serial (connection);
error = NULL;
result = g_dbus_connection_call_finish (connection,
res,
@@ -331,6 +337,9 @@ msg_cb_expect_success (GDBusConnection *connection,
GError *error;
GVariant *result;
/* Make sure gdbusconnection isn't holding @connection's lock. (#747349) */
g_dbus_connection_get_last_serial (connection);
error = NULL;
result = g_dbus_connection_call_finish (connection,
res,
@@ -350,6 +359,9 @@ msg_cb_expect_error_cancelled (GDBusConnection *connection,
GError *error;
GVariant *result;
/* Make sure gdbusconnection isn't holding @connection's lock. (#747349) */
g_dbus_connection_get_last_serial (connection);
error = NULL;
result = g_dbus_connection_call_finish (connection,
res,
@@ -370,6 +382,9 @@ msg_cb_expect_error_cancelled_2 (GDBusConnection *connection,
GError *error;
GVariant *result;
/* Make sure gdbusconnection isn't holding @connection's lock. (#747349) */
g_dbus_connection_get_last_serial (connection);
error = NULL;
result = g_dbus_connection_call_finish (connection,
res,