diff mbox series

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

Message ID 20200716231857.934396-4-luiz.dentz@gmail.com (mailing list archive)
State New, archived
Headers show
Series None | expand

Commit Message

Luiz Augusto von Dentz July 16, 2020, 11:18 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Only remove services that have not been fetched completed as
unsuccessful discovery may be the result of an aborted connection the
attributes that have been fetched previously are likely to be valid.
---
 src/shared/gatt-client.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
index e21aca1f0..5ba8e83ba 100644
--- a/src/shared/gatt-client.c
+++ b/src/shared/gatt-client.c
@@ -407,11 +407,17 @@  static void discovery_op_complete(struct discovery_op *op, bool success,
 	gatt_db_unregister(op->client->db, op->db_id);
 	op->db_id = 0;
 
-	/* Remove services pending */
+	/* Remove staled services */
 	for (svc = queue_get_entries(op->pending_svcs); svc; svc = svc->next) {
 		struct gatt_db_attribute *attr = svc->data;
 		uint16_t start, end;
 
+		/* Don't remove services that already been marked as active
+		 * previously.
+		 */
+		if (gatt_db_service_get_active(attr))
+			continue;
+
 		gatt_db_attribute_get_service_data(attr, &start, &end,
 							NULL, NULL);