Fix gatt disconnected event occured twice issue 50/242450/1
authorWootak Jung <wootak.jung@samsung.com>
Thu, 27 Aug 2020 05:04:59 +0000 (14:04 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Thu, 27 Aug 2020 05:04:59 +0000 (14:04 +0900)
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 <wootak.jung@samsung.com>
bt-service/services/gatt/bt-service-gatt.c

index be34125..f4d73e8 100644 (file)
@@ -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 */