shared/gatt-client: Don't remove active services
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 17 Jul 2020 19:07:01 +0000 (12:07 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 12 Apr 2021 09:00:49 +0000 (14:30 +0530)
If discovery was aborted (i.e due to a disconnect) check if pending
services were active so only staled services which were not completed
fetched are removed.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/shared/gatt-client.c

index 1275b4a..aaab9e3 100644 (file)
@@ -442,6 +442,10 @@ static void discovery_op_complete(struct discovery_op *op, bool success,
                struct gatt_db_attribute *attr = svc->data;
                uint16_t start, end;
 
+               /* Leave active services if operation was aborted */
+               if ((!success && err == 0) && gatt_db_service_get_active(attr))
+                       continue;
+
                gatt_db_attribute_get_service_data(attr, &start, &end,
                                                        NULL, NULL);