2022-08-22 22:29:25

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH BlueZ 1/2] bthost: Add destroy callback to bthost_add_iso_hook

From: Luiz Augusto von Dentz <[email protected]>

This adds a destroy callback to bthost_add_iso_hook so its user can
detect when the hook is freed when the connection is disconnected.
---
emulator/bthost.c | 8 +++++++-
emulator/bthost.h | 3 ++-
tools/iso-tester.c | 2 +-
3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/emulator/bthost.c b/emulator/bthost.c
index f067d39a0262..b05198953506 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -137,6 +137,7 @@ struct rfcomm_chan_hook {
struct iso_hook {
bthost_cid_hook_func_t func;
void *user_data;
+ bthost_destroy_func_t destroy;
};

struct btconn {
@@ -306,6 +307,9 @@ static void btconn_free(struct btconn *conn)
free(hook);
}

+ if (conn->iso_hook && conn->iso_hook->destroy)
+ conn->iso_hook->destroy(conn->iso_hook->user_data);
+
free(conn->iso_hook);
free(conn->recv_data);
free(conn);
@@ -676,7 +680,8 @@ void bthost_add_cid_hook(struct bthost *bthost, uint16_t handle, uint16_t cid,
}

void bthost_add_iso_hook(struct bthost *bthost, uint16_t handle,
- bthost_cid_hook_func_t func, void *user_data)
+ bthost_iso_hook_func_t func, void *user_data,
+ bthost_destroy_func_t destroy)
{
struct iso_hook *hook;
struct btconn *conn;
@@ -693,6 +698,7 @@ void bthost_add_iso_hook(struct bthost *bthost, uint16_t handle,

hook->func = func;
hook->user_data = user_data;
+ hook->destroy = destroy;

conn->iso_hook = hook;
}
diff --git a/emulator/bthost.h b/emulator/bthost.h
index 3d7a124f08ad..2cfdef766e4d 100644
--- a/emulator/bthost.h
+++ b/emulator/bthost.h
@@ -71,7 +71,8 @@ typedef void (*bthost_iso_hook_func_t)(const void *data, uint16_t len,
void *user_data);

void bthost_add_iso_hook(struct bthost *bthost, uint16_t handle,
- bthost_iso_hook_func_t func, void *user_data);
+ bthost_iso_hook_func_t func, void *user_data,
+ bthost_destroy_func_t destroy);

void bthost_send_cid(struct bthost *bthost, uint16_t handle, uint16_t cid,
const void *data, uint16_t len);
diff --git a/tools/iso-tester.c b/tools/iso-tester.c
index 5727f3055222..8c935b9220dd 100644
--- a/tools/iso-tester.c
+++ b/tools/iso-tester.c
@@ -1137,7 +1137,7 @@ static void iso_send(struct test_data *data, GIOChannel *io)
tester_print("Writing %zu bytes of data", isodata->send->iov_len);

host = hciemu_client_get_host(data->hciemu);
- bthost_add_iso_hook(host, data->handle, bthost_recv_data, data);
+ bthost_add_iso_hook(host, data->handle, bthost_recv_data, data, NULL);

ret = writev(sk, isodata->send, 1);
if (ret < 0 || isodata->send->iov_len != (size_t) ret) {
--
2.37.2


2022-08-22 22:31:43

by bluez.test.bot

[permalink] [raw]
Subject: RE: [BlueZ,1/2] bthost: Add destroy callback to bthost_add_iso_hook

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----
error: patch failed: tools/iso-tester.c:1167
error: tools/iso-tester.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch


Please resolve the issue and submit the patches again.


---
Regards,
Linux Bluetooth

2022-08-22 22:45:21

by patchwork-bot+bluetooth

[permalink] [raw]
Subject: Re: [PATCH BlueZ 1/2] bthost: Add destroy callback to bthost_add_iso_hook

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <[email protected]>:

On Mon, 22 Aug 2022 15:00:24 -0700 you wrote:
> From: Luiz Augusto von Dentz <[email protected]>
>
> This adds a destroy callback to bthost_add_iso_hook so its user can
> detect when the hook is freed when the connection is disconnected.
> ---
> emulator/bthost.c | 8 +++++++-
> emulator/bthost.h | 3 ++-
> tools/iso-tester.c | 2 +-
> 3 files changed, 10 insertions(+), 3 deletions(-)

Here is the summary with links:
- [BlueZ,1/2] bthost: Add destroy callback to bthost_add_iso_hook
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=5bf220eb3b86
- [BlueZ,2/2] iso-tester: Make use of bthost_add_iso_hook destroy callback
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=081897da74f0

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html