summaryrefslogtreecommitdiff
path: root/src/gatt-client.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2017-07-18 13:09:04 +0300
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2017-07-18 13:50:42 +0300
commit3349c9cb5d41f7097d29b5d214fc782242ea7ae8 (patch)
tree6e9fdd93022dac94f43102f642425a94caed2d8b /src/gatt-client.c
parente4dae82fb742a3e568aaed2dfb65a123441d92ca (diff)
downloadbluez-3349c9cb5d41f7097d29b5d214fc782242ea7ae8.tar.gz
gatt: Don't return to AcquireNotify until it has completed
Wait until bt_gatt_client_register_notify to reply since the client may need to synchronize the IO.
Diffstat (limited to 'src/gatt-client.c')
-rw-r--r--src/gatt-client.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/gatt-client.c b/src/gatt-client.c
index 66c231856..b5b2ea39c 100644
--- a/src/gatt-client.c
+++ b/src/gatt-client.c
@@ -1187,7 +1187,7 @@ static void characteristic_ready(bool success, uint8_t ecode, void *user_data)
chrc->ready_id = 0;
- if (chrc->write_io->msg) {
+ if (chrc->write_io && chrc->write_io->msg) {
reply = characteristic_create_pipe(chrc, chrc->write_io->msg);
g_dbus_send_message(btd_get_dbus_connection(), reply);
@@ -1196,7 +1196,7 @@ static void characteristic_ready(bool success, uint8_t ecode, void *user_data)
chrc->write_io->msg = NULL;
}
- if (chrc->notify_io->msg) {
+ if (chrc->notify_io && chrc->notify_io->msg) {
reply = characteristic_create_pipe(chrc, chrc->notify_io->msg);
g_dbus_send_message(btd_get_dbus_connection(), reply);
@@ -1426,15 +1426,23 @@ static void register_notify_io_cb(uint16_t att_ecode, void *user_data)
{
struct notify_client *client = user_data;
struct characteristic *chrc = client->chrc;
+ struct bt_gatt_client *gatt = chrc->service->client->gatt;
- if (!att_ecode)
+ if (att_ecode) {
+ queue_remove(chrc->notify_clients, client);
+ notify_client_free(client);
return;
+ }
- queue_remove(chrc->notify_clients, client);
- notify_client_free(client);
+ if (!bt_gatt_client_is_ready(gatt)) {
+ if (!chrc->ready_id)
+ chrc->ready_id = bt_gatt_client_ready_register(gatt,
+ characteristic_ready,
+ chrc, NULL);
+ return;
+ }
- pipe_io_destroy(chrc->notify_io);
- chrc->notify_io = NULL;
+ characteristic_ready(true, 0, chrc);
}
static void notify_io_destroy(void *data)
@@ -1482,18 +1490,10 @@ static DBusMessage *characteristic_acquire_notify(DBusConnection *conn,
chrc->notify_io = new0(struct pipe_io, 1);
chrc->notify_io->data = client;
+ chrc->notify_io->msg = dbus_message_ref(msg);
chrc->notify_io->destroy = notify_io_destroy;
- if (!bt_gatt_client_is_ready(gatt)) {
- if (!chrc->ready_id)
- chrc->ready_id = bt_gatt_client_ready_register(gatt,
- characteristic_ready,
- chrc, NULL);
- chrc->notify_io->msg = dbus_message_ref(msg);
- return NULL;
- }
-
- return characteristic_create_pipe(chrc, msg);
+ return NULL;
}
static DBusMessage *characteristic_start_notify(DBusConnection *conn,