Comment some places where it's OK to unref a message despite holding locks
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Fri, 25 Feb 2011 17:08:59 +0000 (17:08 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Thu, 28 Jul 2011 17:23:25 +0000 (18:23 +0100)
In general, dbus_message_unref should be avoided while holding locks,
because it can invoke arbitrary user callbacks (via attached data, or
via DBusCounter).

Reviewed-by: Colin Walters <walters@verbum.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34393

dbus/dbus-connection.c
dbus/dbus-pending-call.c

index fad69c7..a917f9a 100644 (file)
@@ -4701,6 +4701,8 @@ dbus_connection_dispatch (DBusConnection *connection)
 
       if (preallocated == NULL)
         {
+          /* It's OK that this is finalized, because it hasn't been seen by
+           * anything that could attach user callbacks */
           dbus_message_unref (reply);
           result = DBUS_HANDLER_RESULT_NEED_MEMORY;
           _dbus_verbose ("no memory for error send in dispatch\n");
index cfb2baf..f961319 100644 (file)
@@ -353,6 +353,8 @@ _dbus_pending_call_set_timeout_error_unlocked (DBusPendingCall *pending,
   reply_link = _dbus_list_alloc_link (reply);
   if (reply_link == NULL)
     {
+      /* it's OK to unref this, nothing that could have attached a callback
+       * has ever seen it */
       dbus_message_unref (reply);
       return FALSE;
     }