* [PATCH BlueZ 1/2] core: Fixes order InterfaceAdded
@ 2018-02-09 10:53 Luiz Augusto von Dentz
2018-02-09 10:53 ` [PATCH BlueZ] shared/gatt-client: Reset callbacks when unregistering Luiz Augusto von Dentz
2018-02-09 10:53 ` [PATCH BlueZ 2/2] " Luiz Augusto von Dentz
0 siblings, 2 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2018-02-09 10:53 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Registering on the callback of MGMT_OP_READ_ADV_FEATURES causes
InterfacesAdded to be reschedule after the device objects which causes
tools such as PulseAudio to consider it invalid.
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1534857
---
src/advertising.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/src/advertising.c b/src/advertising.c
index 94a8c4050..970c3d87b 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -1032,14 +1032,6 @@ static void read_adv_features_callback(uint8_t status, uint16_t length,
if (manager->max_ads == 0)
return;
- if (!g_dbus_register_interface(btd_get_dbus_connection(),
- adapter_get_path(manager->adapter),
- LE_ADVERTISING_MGR_IFACE, methods,
- NULL, properties, manager, NULL)) {
- error("Failed to register " LE_ADVERTISING_MGR_IFACE);
- return;
- }
-
/* Reset existing instances */
if (feat->num_instances)
remove_advertising(manager, 0);
@@ -1061,19 +1053,29 @@ static struct btd_adv_manager *manager_create(struct btd_adapter *adapter)
}
manager->mgmt_index = btd_adapter_get_index(adapter);
+ manager->clients = queue_new();
+ manager->supported_flags = MGMT_ADV_FLAG_LOCAL_NAME;
+
+ if (!g_dbus_register_interface(btd_get_dbus_connection(),
+ adapter_get_path(manager->adapter),
+ LE_ADVERTISING_MGR_IFACE, methods,
+ NULL, properties, manager, NULL)) {
+ error("Failed to register " LE_ADVERTISING_MGR_IFACE);
+ goto fail;
+ }
if (!mgmt_send(manager->mgmt, MGMT_OP_READ_ADV_FEATURES,
manager->mgmt_index, 0, NULL,
read_adv_features_callback, manager, NULL)) {
error("Failed to read advertising features");
- manager_destroy(manager);
- return NULL;
+ goto fail;
}
- manager->clients = queue_new();
- manager->supported_flags = MGMT_ADV_FLAG_LOCAL_NAME;
-
return manager;
+
+fail:
+ manager_destroy(manager);
+ return NULL;
}
struct btd_adv_manager *btd_adv_manager_new(struct btd_adapter *adapter)
--
2.14.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH BlueZ] shared/gatt-client: Reset callbacks when unregistering
2018-02-09 10:53 [PATCH BlueZ 1/2] core: Fixes order InterfaceAdded Luiz Augusto von Dentz
@ 2018-02-09 10:53 ` Luiz Augusto von Dentz
2018-02-09 10:53 ` [PATCH BlueZ 2/2] " Luiz Augusto von Dentz
1 sibling, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2018-02-09 10:53 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If user application is unregistering a notification handler its
callbacks shall not be called even CCC write is still holding a
reference to notify_data.
---
src/shared/gatt-client.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
index 8083ff719..1285c37ef 100644
--- a/src/shared/gatt-client.c
+++ b/src/shared/gatt-client.c
@@ -1212,7 +1212,9 @@ static void complete_notify_request(void *data)
struct notify_data *notify_data = data;
notify_data->att_id = 0;
- notify_data->callback(0, notify_data->user_data);
+
+ if (notify_data->callback)
+ notify_data->callback(0, notify_data->user_data);
}
static bool notify_data_write_ccc(struct notify_data *notify_data, bool enable,
@@ -3157,6 +3159,10 @@ bool bt_gatt_client_unregister_notify(struct bt_gatt_client *client,
/* Remove data if it has been queued */
queue_remove(notify_data->chrc->reg_notify_queue, notify_data);
+ /* Reset callbacks */
+ notify_data->callback = NULL;
+ notify_data->notify = NULL;
+
complete_unregister_notify(notify_data);
return true;
}
--
2.14.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH BlueZ 2/2] shared/gatt-client: Reset callbacks when unregistering
2018-02-09 10:53 [PATCH BlueZ 1/2] core: Fixes order InterfaceAdded Luiz Augusto von Dentz
2018-02-09 10:53 ` [PATCH BlueZ] shared/gatt-client: Reset callbacks when unregistering Luiz Augusto von Dentz
@ 2018-02-09 10:53 ` Luiz Augusto von Dentz
2018-02-12 11:28 ` Luiz Augusto von Dentz
1 sibling, 1 reply; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2018-02-09 10:53 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If user application is unregistering a notification handler its
callbacks shall not be called even CCC write is still holding a
reference to notify_data.
---
src/shared/gatt-client.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
index 8083ff719..1285c37ef 100644
--- a/src/shared/gatt-client.c
+++ b/src/shared/gatt-client.c
@@ -1212,7 +1212,9 @@ static void complete_notify_request(void *data)
struct notify_data *notify_data = data;
notify_data->att_id = 0;
- notify_data->callback(0, notify_data->user_data);
+
+ if (notify_data->callback)
+ notify_data->callback(0, notify_data->user_data);
}
static bool notify_data_write_ccc(struct notify_data *notify_data, bool enable,
@@ -3157,6 +3159,10 @@ bool bt_gatt_client_unregister_notify(struct bt_gatt_client *client,
/* Remove data if it has been queued */
queue_remove(notify_data->chrc->reg_notify_queue, notify_data);
+ /* Reset callbacks */
+ notify_data->callback = NULL;
+ notify_data->notify = NULL;
+
complete_unregister_notify(notify_data);
return true;
}
--
2.14.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH BlueZ 2/2] shared/gatt-client: Reset callbacks when unregistering
2018-02-09 10:53 ` [PATCH BlueZ 2/2] " Luiz Augusto von Dentz
@ 2018-02-12 11:28 ` Luiz Augusto von Dentz
0 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2018-02-12 11:28 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org
Hi,
On Fri, Feb 9, 2018 at 8:53 AM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> If user application is unregistering a notification handler its
> callbacks shall not be called even CCC write is still holding a
> reference to notify_data.
> ---
> src/shared/gatt-client.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
> index 8083ff719..1285c37ef 100644
> --- a/src/shared/gatt-client.c
> +++ b/src/shared/gatt-client.c
> @@ -1212,7 +1212,9 @@ static void complete_notify_request(void *data)
> struct notify_data *notify_data = data;
>
> notify_data->att_id = 0;
> - notify_data->callback(0, notify_data->user_data);
> +
> + if (notify_data->callback)
> + notify_data->callback(0, notify_data->user_data);
> }
>
> static bool notify_data_write_ccc(struct notify_data *notify_data, bool enable,
> @@ -3157,6 +3159,10 @@ bool bt_gatt_client_unregister_notify(struct bt_gatt_client *client,
> /* Remove data if it has been queued */
> queue_remove(notify_data->chrc->reg_notify_queue, notify_data);
>
> + /* Reset callbacks */
> + notify_data->callback = NULL;
> + notify_data->notify = NULL;
> +
> complete_unregister_notify(notify_data);
> return true;
> }
> --
> 2.14.3
Applied.
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-02-12 11:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-09 10:53 [PATCH BlueZ 1/2] core: Fixes order InterfaceAdded Luiz Augusto von Dentz
2018-02-09 10:53 ` [PATCH BlueZ] shared/gatt-client: Reset callbacks when unregistering Luiz Augusto von Dentz
2018-02-09 10:53 ` [PATCH BlueZ 2/2] " Luiz Augusto von Dentz
2018-02-12 11:28 ` Luiz Augusto von Dentz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).