From 94715ea46015fcac68803ce3a5da8b9c2ec6e07d Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Thu, 1 Feb 2024 15:16:04 +0900 Subject: [PATCH] Fix to reallocate fd when gatt write fails Change-Id: Ic9e2cf70d022c1d0f66b45587f08b382cd425421 Signed-off-by: Wootak Jung --- bt-api/bt-gatt-client.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/bt-api/bt-gatt-client.c b/bt-api/bt-gatt-client.c index a370502..187e0a4 100644 --- a/bt-api/bt-gatt-client.c +++ b/bt-api/bt-gatt-client.c @@ -2489,6 +2489,21 @@ static int bluetooth_gatt_client_write_characteristics_value_to_fd( if (written != length) { att_result = BLUETOOTH_ERROR_INTERNAL; BT_ERR("write data failed. ret : %d ", written); + if (TIZEN_FEATURE_DA_REFERENCE) { + /* If bluetooth_gatt_client_write_channel_watch_cb() is not called + * due to a server issue and write request fails, + * remove the existing fd from the list and reallocate it.*/ + GSList *l; + for (l = gatt_characteristic_write_list; l != NULL; l = l->next) { + bt_gatt_characteristic_write_info_t *info = l->data; + if (!info) + continue; + if (info->write_fd == fd) { + gatt_characteristic_write_list = g_slist_remove(gatt_characteristic_write_list, info); + break; + } + } + } } return att_result; -- 2.7.4