From eda1c575f1bafe4eb3222cb87d5dd4562055bf2d Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Thu, 27 Aug 2020 14:04:59 +0900 Subject: [PATCH] Fix gatt disconnected event occured twice issue gatt server start > gatt connected > gatt disconnected from client > two disconnected event occured Remove client info if existing even if remote client disconnected Change-Id: I969ecb97c4ae4c1597cb72538cf8fe476652f59f Signed-off-by: Wootak Jung --- bt-service/services/gatt/bt-service-gatt.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/bt-service/services/gatt/bt-service-gatt.c b/bt-service/services/gatt/bt-service-gatt.c index be34125..f4d73e8 100644 --- a/bt-service/services/gatt/bt-service-gatt.c +++ b/bt-service/services/gatt/bt-service-gatt.c @@ -3087,10 +3087,11 @@ static void __bt_handle_client_connected(event_gattc_conn_t *event_data) static void __bt_handle_client_disconnected(event_gattc_conn_t *event_data) { int result = BLUETOOTH_ERROR_NONE; - struct gatt_server_info_t *conn_info = NULL; +#ifndef __INTEGRATE_GATT_INFO__ + struct gatt_client_info_t *client_info = NULL; +#endif struct gatt_out_conn_info_t *out_conn_info = NULL; - GVariant *param = NULL; char *address = g_malloc0(BT_ADDRESS_STRING_SIZE); @@ -3139,6 +3140,17 @@ static void __bt_handle_client_disconnected(event_gattc_conn_t *event_data) } else BT_INFO("Can not find conn info, already removed!"); +#ifndef __INTEGRATE_GATT_INFO__ + /* Remove client info */ + client_info = _bt_find_remote_gatt_client_info(address); + if (client_info) { + BT_DBG("Remove GATT client info from list"); + gatt_client_info_list = g_slist_remove(gatt_client_info_list, client_info); + g_free(client_info->addr); + g_free(client_info); + } +#endif + __bt_remove_mtu_gatt_device(address); /* If outgoing connection Info is present, then remove it */ -- 2.7.4