Thread (37 messages) flat view 37 messages, 3 authors, 2011-07-27

Re: [PATCH BlueZ 08/12] Drop GAttrib ref if callback list is empty

From: Claudio Takahasi <hidden>
Date: 2011-07-14 16:29:49

Hi Johan/Lizardo,

On Thu, Jul 14, 2011 at 12:17 PM, Johan Hedberg [off-list ref] wrote:
Hi Lizardo,

On Thu, Jul 14, 2011, Anderson Lizardo wrote:
quoted
On Thu, Jul 14, 2011 at 10:44 AM, Johan Hedberg [off-list ref] wrote:
quoted
quoted
@@ -2605,10 +2605,15 @@ gboolean btd_device_remove_attio_callback(struct btd_device *device, guint id)
      g_free(attio);

+     if (device->attios != NULL)
+             return TRUE;
+
      if (device->attioid) {
              g_source_remove(device->attioid);
              device->attioid = 0;
      }

+     g_attrib_unref(device->attrib);
+
      return TRUE;
 }
Looks like you're missing a device->attrib = NULL; after the unref.
I really don't see the point in setting a reference counted variable
to NULL. How would we know whether this is the last usage or not?
You're not supposed to know. All you know is that device->attrib is one
reference to the GAttrib object. Calling unref is akin to saying "this
pointer is no longer valid" and since the btd_device object keeps living
after this function you should set the ->attrib pointer to NULL after
dropping this reference.

Johan
GAttrib destroy callback will set device->attrib to NULL. I gonna send
a new patch setting it to NULL explicitly and avoid misunderstandings.

Regards,
Claudio
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help