DBusConnection: ref the connection in the timeout handler
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Thu, 20 Jan 2011 15:48:07 +0000 (15:48 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 13 Jun 2011 15:04:39 +0000 (16:04 +0100)
client_timeout_callback in bus/test.c refs the connection across the
timeout invocation, which looks suspiciously like a workaround. If we
make the timeout handler itself ref the connection, we won't need that,
and can simplify timeout handling drastically.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33342
Reviewed-by: Thiago Macieira <thiago@kde.org>
bus/test.c
dbus/dbus-connection.c

index 6efad6e..95c7cfb 100644 (file)
@@ -76,12 +76,8 @@ client_timeout_callback (DBusTimeout   *timeout,
 {
   DBusConnection *connection = data;
 
-  dbus_connection_ref (connection);
-
   /* can return FALSE on OOM but we just let it fire again later */
   dbus_timeout_handle (timeout);
-
-  dbus_connection_unref (connection);
 }
 
 static dbus_bool_t
index 1a7079d..9ec85c0 100644 (file)
@@ -3276,6 +3276,7 @@ reply_handler_timeout (void *data)
   DBusPendingCall *pending = data;
 
   connection = _dbus_pending_call_get_connection_and_lock (pending);
+  _dbus_connection_ref_unlocked (connection);
 
   _dbus_pending_call_queue_timeout_error_unlocked (pending, 
                                                    connection);
@@ -3288,6 +3289,7 @@ reply_handler_timeout (void *data)
 
   /* Unlocks, and calls out to user code */
   _dbus_connection_update_dispatch_status_and_unlock (connection, status);
+  dbus_connection_unref (connection);
   
   return TRUE;
 }