aboutsummaryrefslogtreecommitdiffstats
path: root/attrib/client.c
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2011-12-21 18:41:49 -0300
committerJohan Hedberg <johan.hedberg@intel.com>2011-12-27 12:04:49 +0200
commitf583bef247cea1def6c78045fa623ed03b42cca5 (patch)
tree29fd79d1ca481caf0eb746cd3fdd6ec41a68ff78 /attrib/client.c
parent6e4a000cab7e82bc58ae0795c47aeb6ea253a090 (diff)
downloadbluez-f583bef247cea1def6c78045fa623ed03b42cca5.tar.gz
bluez-f583bef247cea1def6c78045fa623ed03b42cca5.tar.xz
bluez-f583bef247cea1def6c78045fa623ed03b42cca5.zip
attrib-client: Fix GAttrib reference counting
Although ATT connection callbacks control GAttrib reference, each entity using GAttrib should be increment the GAttrib reference to keep the code standard.
Diffstat (limited to 'attrib/client.c')
-rw-r--r--attrib/client.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/attrib/client.c b/attrib/client.c
index ef7152a2..380a288a 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -318,7 +318,7 @@ static void attio_connected(GAttrib *attrib, gpointer user_data)
{
struct gatt_service *gatt = user_data;
- gatt->attrib = attrib;
+ gatt->attrib = g_attrib_ref(attrib);
g_attrib_register(gatt->attrib, ATT_OP_HANDLE_NOTIFY,
events_handler, gatt, NULL);
@@ -332,7 +332,10 @@ static void attio_disconnected(gpointer user_data)
{
struct gatt_service *gatt = user_data;
- gatt->attrib = NULL;
+ if (gatt->attrib) {
+ g_attrib_unref(gatt->attrib);
+ gatt->attrib = NULL;
+ }
}
static DBusMessage *register_watcher(DBusConnection *conn,
@@ -892,7 +895,7 @@ static void send_discover(GAttrib *attrib, gpointer user_data)
struct gatt_service *gatt = qchr->gatt;
struct att_primary *prim = gatt->prim;
- gatt->attrib = attrib;
+ gatt->attrib = g_attrib_ref(attrib);
gatt_discover_char(gatt->attrib, prim->start, prim->end, NULL,
char_discovered_cb, qchr);
@@ -903,6 +906,7 @@ static void cancel_discover(gpointer user_data)
struct query_data *qchr = user_data;
struct gatt_service *gatt = qchr->gatt;
+ g_attrib_unref(gatt->attrib);
gatt->attrib = NULL;
}