]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
[DBusConnection] When handling a watch, return if another thread is doing I/O
authorMichael Meeks <michael.meeks@novell.com>
Fri, 12 Mar 2010 16:50:27 +0000 (11:50 -0500)
committerColin Walters <walters@verbum.org>
Fri, 12 Mar 2010 16:50:27 +0000 (11:50 -0500)
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>
dbus/dbus-connection.c

index 5fb234dcadaae82a32ac3aa50083ef9906ad2479..69fdf5306b9c23c4b3ac84493c8ad3c3ebc5225d 100644 (file)
@@ -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);