aboutsummaryrefslogtreecommitdiffstats
path: root/attrib/client.c
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2010-09-17 17:26:57 -0300
committerAnderson Lizardo <anderson.lizardo@openbossa.org>2010-09-22 15:55:18 -0400
commitd0bfd6eaa586b86bc1b191de0cb9c12e331a22fa (patch)
treedaab00a2bb17cad213050cd7de6ddcaa32e130e9 /attrib/client.c
parent8545bdc1eae7c4e4a6ef90c74b3e6c070e3bbe9c (diff)
downloadbluez-d0bfd6eaa586b86bc1b191de0cb9c12e331a22fa.tar.gz
bluez-d0bfd6eaa586b86bc1b191de0cb9c12e331a22fa.tar.xz
bluez-d0bfd6eaa586b86bc1b191de0cb9c12e331a22fa.zip
Use the destroy function to reset the GAttrib reference
In the client, after local or remote initiated disconnection the GAttrib reference shall be set to NULL to allow a proper control of references and further connections.
Diffstat (limited to 'attrib/client.c')
-rw-r--r--attrib/client.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/attrib/client.c b/attrib/client.c
index d695e235..a3c01a11 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -316,12 +316,19 @@ static void events_handler(const uint8_t *pdu, uint16_t len,
static void primary_cb(guint8 status, const guint8 *pdu, guint16 plen,
gpointer user_data);
+static void attrib_destroy(gpointer user_data)
+{
+ struct gatt_service *gatt = user_data;
+
+ gatt->attrib = NULL;
+}
+
static void attrib_disconnect(gpointer user_data)
{
struct gatt_service *gatt = user_data;
+ /* Remote initiated disconnection only */
g_attrib_unref(gatt->attrib);
- gatt->attrib = NULL;
}
static void connect_cb(GIOChannel *chan, GError *gerr, gpointer user_data)
@@ -452,9 +459,8 @@ static DBusMessage *register_watcher(DBusConnection *conn,
g_io_channel_unref(io);
gatt->listen = TRUE;
- if (prim->watchers == NULL)
- g_attrib_set_disconnect_function(gatt->attrib,
- attrib_disconnect, gatt);
+ g_attrib_set_destroy_function(gatt->attrib, attrib_destroy, gatt);
+ g_attrib_set_disconnect_function(gatt->attrib, attrib_disconnect, gatt);
done:
watcher = g_new0(struct watcher, 1);
@@ -1260,6 +1266,7 @@ int attrib_client_register(bdaddr_t *sba, bdaddr_t *dba, const char *path,
gatt->attrib = g_attrib_new(io);
g_io_channel_unref(io);
+ g_attrib_set_destroy_function(gatt->attrib, attrib_destroy, gatt);
g_attrib_set_disconnect_function(gatt->attrib, attrib_disconnect,
gatt);