summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@novell.com>2010-03-12 11:50:27 -0500
committerColin Walters <walters@verbum.org>2010-03-12 11:50:27 -0500
commitae95a0ff9651a774cd983436d7e656c62492659c (patch)
treef78c950eda1d0efd0f6f2da0d77b8181873a6491
parent008cd59ef713a1efc3c9588cf1079c6a80ddf0c7 (diff)
downloaddbus-ae95a0ff9651a774cd983436d7e656c62492659c.tar.gz
[DBusConnection] When handling a watch, return if another thread is doing I/O
http://lists.freedesktop.org/archives/dbus/2010-March/012337.html Previously, the watch handler would block until the I/O path was available. However, if another non-main thread was doing a synchronous call, this would cause the main thread to block on that thread, a highly undesirable thing because it's important for the main thread to remain responsive for user interfaces. Signed-off-by: Colin Walters <walters@verbum.org> Signed-off-by: Thiago Macieira <thiago@kde.org>
-rw-r--r--dbus/dbus-connection.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c
index 5fb234dc..69fdf530 100644
--- a/dbus/dbus-connection.c
+++ b/dbus/dbus-connection.c
@@ -1435,7 +1435,14 @@ _dbus_connection_handle_watch (DBusWatch *watch,
_dbus_verbose ("%s start\n", _DBUS_FUNCTION_NAME);
CONNECTION_LOCK (connection);
- _dbus_connection_acquire_io_path (connection, -1);
+
+ if (!_dbus_connection_acquire_io_path (connection, 1))
+ {
+ /* another thread is handling the message */
+ CONNECTION_UNLOCK (connection);
+ return TRUE;
+ }
+
HAVE_LOCK_CHECK (connection);
retval = _dbus_transport_handle_watch (connection->transport,
watch, condition);