From: Luiz Augusto von Dentz <[email protected]>
If the transport has links check if the link is acquiring before
attempting to call Acquire otherwise it may cause an error to be
printed.
---
client/player.c | 70 +++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 65 insertions(+), 5 deletions(-)
diff --git a/client/player.c b/client/player.c
index 30ae263c8e41..4324089345c1 100644
--- a/client/player.c
+++ b/client/player.c
@@ -65,6 +65,7 @@ struct endpoint {
uint8_t codec;
struct iovec *caps;
bool auto_accept;
+ bool acquiring;
uint8_t cig;
uint8_t cis;
char *transport;
@@ -2688,6 +2689,30 @@ static struct endpoint *find_ep_by_transport(const char *path)
return NULL;
}
+static struct endpoint *find_link_by_proxy(GDBusProxy *proxy)
+{
+ DBusMessageIter iter, array;
+
+ if (!g_dbus_proxy_get_property(proxy, "Links", &iter))
+ return NULL;
+
+ dbus_message_iter_recurse(&iter, &array);
+
+ while (dbus_message_iter_get_arg_type(&array) ==
+ DBUS_TYPE_OBJECT_PATH) {
+ const char *transport;
+ struct endpoint *link;
+
+ dbus_message_iter_get_basic(&array, &transport);
+
+ link = find_ep_by_transport(transport);
+ if (link)
+ return link;
+ }
+
+ return NULL;
+}
+
static void transport_close(struct transport *transport)
{
if (transport->fd < 0)
@@ -2769,10 +2794,19 @@ static void transport_new(GDBusProxy *proxy, int sk, uint16_t mtu[2])
static void acquire_reply(DBusMessage *message, void *user_data)
{
GDBusProxy *proxy = user_data;
+ struct endpoint *ep, *link;
DBusError error;
int sk;
uint16_t mtu[2];
+ ep = find_ep_by_transport(g_dbus_proxy_get_path(proxy));
+ if (ep) {
+ ep->acquiring = false;
+ link = find_link_by_proxy(proxy);
+ if (link)
+ link->acquiring = false;
+ }
+
dbus_error_init(&error);
if (dbus_set_error_from_message(&error, message) == TRUE) {
@@ -2803,11 +2837,22 @@ static void acquire_reply(DBusMessage *message, void *user_data)
static void transport_acquire(const char *input, void *user_data)
{
GDBusProxy *proxy = user_data;
+ struct endpoint *ep, *link;
if (!strcasecmp(input, "y") || !strcasecmp(input, "yes")) {
- if (!g_dbus_proxy_method_call(proxy, "Acquire", NULL,
+ if (g_dbus_proxy_method_call(proxy, "Acquire", NULL,
acquire_reply, proxy, NULL))
- bt_shell_printf("Failed acquire transport\n");
+ return;
+ bt_shell_printf("Failed acquire transport\n");
+ }
+
+ /* Reset acquiring */
+ ep = find_ep_by_transport(g_dbus_proxy_get_path(proxy));
+ if (ep) {
+ ep->acquiring = false;
+ link = find_link_by_proxy(proxy);
+ if (link)
+ link->acquiring = false;
}
}
@@ -2815,7 +2860,7 @@ static void transport_property_changed(GDBusProxy *proxy, const char *name,
DBusMessageIter *iter)
{
char *str;
- struct endpoint *ep;
+ struct endpoint *ep, *link;
str = proxy_description(proxy, "Transport", COLORED_CHG);
print_iter(str, name, iter);
@@ -2833,14 +2878,29 @@ static void transport_property_changed(GDBusProxy *proxy, const char *name,
* endpoint.
*/
ep = find_ep_by_transport(g_dbus_proxy_get_path(proxy));
- if (!ep)
+ if (!ep || ep->acquiring)
return;
+ ep->acquiring = true;
+
+ link = find_link_by_proxy(proxy);
+ if (link) {
+ bt_shell_printf("Link %s found\n", link->transport);
+ /* If link already acquiring wait it to be complete */
+ if (link->acquiring)
+ return;
+ link->acquiring = true;
+ }
+
if (ep->auto_accept) {
bt_shell_printf("Auto Acquiring...\n");
if (!g_dbus_proxy_method_call(proxy, "Acquire", NULL,
- acquire_reply, proxy, NULL))
+ acquire_reply, proxy, NULL)) {
bt_shell_printf("Failed acquire transport\n");
+ ep->acquiring = false;
+ if (link)
+ link->acquiring = false;
+ }
return;
}
--
2.37.3
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=681654
---Test result---
Test Summary:
CheckPatch PASS 1.78 seconds
GitLint PASS 1.07 seconds
Prep - Setup ELL PASS 27.06 seconds
Build - Prep PASS 0.86 seconds
Build - Configure PASS 8.89 seconds
Build - Make PASS 982.74 seconds
Make Check PASS 12.12 seconds
Make Check w/Valgrind PASS 295.34 seconds
Make Distcheck PASS 245.68 seconds
Build w/ext ELL - Configure PASS 8.86 seconds
Build w/ext ELL - Make PASS 85.98 seconds
Incremental Build w/ patches PASS 0.00 seconds
Scan Build WARNING 521.33 seconds
Details
##############################
Test: Scan Build - WARNING
Desc: Run Scan Build with patches
Output:
*****************************************************************************
The bugs reported by the scan-build may or may not be caused by your patches.
Please check the list and fix the bugs if they are caused by your patch.
*****************************************************************************
client/player.c:1756:25: warning: Dereference of null pointer
iov_append(&cfg->caps, preset->data.iov_base, preset->data.iov_len);
^~~~~~~~~~~~~~~~~~~~~
1 warning generated.
---
Regards,
Linux Bluetooth
Hello:
This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <[email protected]>:
On Wed, 28 Sep 2022 14:26:49 -0700 you wrote:
> From: Luiz Augusto von Dentz <[email protected]>
>
> If the transport has links check if the link is acquiring before
> attempting to call Acquire otherwise it may cause an error to be
> printed.
> ---
> client/player.c | 70 +++++++++++++++++++++++++++++++++++++++++++++----
> 1 file changed, 65 insertions(+), 5 deletions(-)
Here is the summary with links:
- [BlueZ] client/player: Fix attempting to acquire already acquired transport
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=25a31f5a930e
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html