diff mbox series

[BlueZ,4/5] shared/gatt-client: Don't remove active services

Message ID 20200717191515.220621-4-luiz.dentz@gmail.com (mailing list archive)
State New, archived
Headers show
Series [BlueZ,1/5] shared/att: Fix possible crash on disconnect | expand

Commit Message

Luiz Augusto von Dentz July 17, 2020, 7:15 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

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.
---
 src/shared/gatt-client.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
index e21aca1f0..409a3ee57 100644
--- a/src/shared/gatt-client.c
+++ b/src/shared/gatt-client.c
@@ -412,6 +412,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);