cleanup of acquire notification data for stop notify 45/198845/1
authorAmit Purwar <amit.purwar@samsung.com>
Wed, 30 Jan 2019 09:00:31 +0000 (14:30 +0530)
committerAmit Purwar <amit.purwar@samsung.com>
Wed, 30 Jan 2019 09:00:31 +0000 (14:30 +0530)
Change-Id: I75cb3a0edbd159789695cc8c16ae659cc246c5bf
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
bt-api/bt-gatt-service.c

index 91149a8a2107ed2c90ae139f6c1727d109ba5700..e39c3a0c75a81e2c02425031c744b0a63b40838d 100644 (file)
@@ -405,12 +405,20 @@ static gboolean bluetooth_gatt_write_channel_watch_cb(GIOChannel *gio,
                g_io_channel_shutdown(gio, TRUE, NULL);
                g_io_channel_unref(gio);
 
-               gatt_characteristic_server_notify_list = g_slist_remove(gatt_characteristic_server_notify_list, chr_info);
-               bluetooth_characteristic_info_free(chr_info);
+               if (g_slist_find(gatt_characteristic_server_notify_list, chr_info)) {
+                       BT_INFO("found char_info in the list");
+                       gatt_characteristic_server_notify_list = g_slist_remove(gatt_characteristic_server_notify_list, chr_info);
+                       bluetooth_characteristic_info_free(chr_info);
+               }
 
                return FALSE;
        }
 
+       if (g_slist_find(gatt_characteristic_server_notify_list, chr_info) == NULL) {
+               BT_INFO("chr_info is not in the list");
+               return FALSE;
+       }
+
        return TRUE;
 }
 
@@ -3338,5 +3346,9 @@ void cleanup_gatt_acquire_fd(int handle)
                        BT_INFO("closing fd");
                        close(chr_info->write_fd);
                }
+
+               BT_INFO("Removing char_info from the list");
+               gatt_characteristic_server_notify_list = g_slist_remove(gatt_characteristic_server_notify_list, chr_info);
+               bluetooth_characteristic_info_free(chr_info);
        }
 }