shared/gatt-client: Fix removing services from pending list 53/204953/1
authorAndrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Thu, 22 Mar 2018 15:20:59 +0000 (16:20 +0100)
committerAmit Purwar <amit.purwar@samsung.com>
Fri, 26 Apr 2019 10:53:34 +0000 (16:23 +0530)
We should remove from pending list service which was just processed,
not the one that has just started being processed.

Change-Id: I045bc1964f0951f6fae4d116acb973d70161a801
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
src/shared/gatt-client.c

index a681f26..ac308b6 100644 (file)
@@ -650,10 +650,13 @@ static bool discover_descs(struct discovery_op *op, bool *discovering)
                /* Adjust current service */
                svc = gatt_db_get_service(client->db, chrc_data->value_handle);
                if (op->cur_svc != svc) {
-                       queue_remove(op->pending_svcs, svc);
+                       if (op->cur_svc) {
+                               queue_remove(op->pending_svcs, op->cur_svc);
+
+                               /* Done with the current service */
+                               gatt_db_service_set_active(op->cur_svc, true);
+                       }
 
-                       /* Done with the current service */
-                       gatt_db_service_set_active(op->cur_svc, true);
                        op->cur_svc = svc;
                }