summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2023-02-28 14:22:31 -0800
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2023-03-02 12:19:39 -0800
commit36c234625bda881bc9d5bd99305706b86d117716 (patch)
treed0207590dd61adaf4e7a6bdd8239ce11e5e725ab /src
parent24aeb319610b96f938ff7772e15bf0409813eaa4 (diff)
downloadbluez-36c234625bda881bc9d5bd99305706b86d117716.tar.gz
shared/bap: Cleanup requests on detach
If session is being detached any ongoing/queue request shall be cancelled as well otherwise when the session is attach again they would be invalid.
Diffstat (limited to 'src')
-rw-r--r--src/shared/bap.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/shared/bap.c b/src/shared/bap.c
index 41b39f868..c0f35e1c9 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -3818,6 +3818,13 @@ static void stream_foreach_detach(void *data, void *user_data)
stream_set_state(stream, BT_BAP_STREAM_STATE_IDLE);
}
+static void bap_req_detach(void *data)
+{
+ struct bt_bap_req *req = data;
+
+ bap_req_complete(req, NULL);
+}
+
void bt_bap_detach(struct bt_bap *bap)
{
DBG(bap, "%p", bap);
@@ -3825,6 +3832,15 @@ void bt_bap_detach(struct bt_bap *bap)
if (!queue_remove(sessions, bap))
return;
+ /* Cancel ongoing request */
+ if (bap->req) {
+ bap_req_detach(bap->req);
+ bap->req = NULL;
+ }
+
+ /* Cancel queued requests */
+ queue_remove_all(bap->reqs, NULL, NULL, bap_req_detach);
+
bt_gatt_client_unref(bap->client);
bap->client = NULL;