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

Re: [PATCH BlueZ 10/12] Manage GAttrib refs based on registered callbacks

From: Johan Hedberg <hidden>
Date: 2011-07-14 17:12:13

Hi Claudio,

On Wed, Jul 06, 2011, Claudio Takahasi wrote:
Connection should not be dropped if there is at least one ATT connection
callback registered.
---
 src/device.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)
Patches 8 and 9 have now been pushed, but there's some reference
counting weirdness going on here again:
quoted hunk ↗ jump to hunk
--- a/src/device.c
+++ b/src/device.c
@@ -1664,6 +1664,7 @@ static void primary_cb(GSList *services, guint8 status, gpointer user_data)
 done:
 	device->browse = NULL;
 	browse_request_free(req, shutdown);
+	g_attrib_unref(device->attrib);
 }
Where's the device->attrib = NULL?
quoted hunk ↗ jump to hunk
@@ -2568,18 +2569,22 @@ guint btd_device_add_attio_callback(struct btd_device *device,
 	attio->dcfunc = dcfunc;
 	attio->user_data = user_data;
 
-	device->attios = g_slist_append(device->attios, attio);
-
-	if (device->attrib && cfunc)
-		cfunc(device->attrib, user_data);
+	if (device->attrib) {
+		/* First element */
+		if (device->attios == NULL)
+			device->attrib = g_attrib_ref(device->attrib);
Eh? It looks like attio is supposed to own this reference created by
g_attrib_ref() so you should really be assigning the return value to
attio->attrib. Or is it so that device->attrib is actually there only
for any elements in the device->attios list? If that's the case then
it's fine to have just create device->attrib when you add the first
element to the list and unref + set to NULL when you remove the last
element from the list.

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