summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2019-02-12 13:38:46 +0200
committerhimanshu <h.himanshu@samsung.com>2020-02-11 14:27:47 +0530
commit99d124bbc83d7dbaecb1498c3b25fe878042b6b8 (patch)
tree209046612b2b9c25e306d8f4eb36b8c884ff7944 /client
parent770431015dce005c345e9ef50173cfd67926e959 (diff)
downloadbluez-99d124bbc83d7dbaecb1498c3b25fe878042b6b8.tar.gz
bluez-99d124bbc83d7dbaecb1498c3b25fe878042b6b8.tar.bz2
bluez-99d124bbc83d7dbaecb1498c3b25fe878042b6b8.zip
client: Remove cloned services if the proxy is removed
This unregister the cloned services if the proxy is removed since they would no longer be accessible. Change-Id: I657787c1f534cc2493e77a61f3f062dca20494ec Signed-off-by: himanshu <h.himanshu@samsung.com>
Diffstat (limited to 'client')
-rwxr-xr-xclient/gatt.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/client/gatt.c b/client/gatt.c
index f3524ed4..afe8e2e3 100755
--- a/client/gatt.c
+++ b/client/gatt.c
@@ -201,8 +201,25 @@ void gatt_add_service(GDBusProxy *proxy)
print_service_proxy(proxy, COLORED_NEW);
}
+static struct service *remove_service_by_proxy(struct GDBusProxy *proxy)
+{
+ GList *l;
+
+ for (l = local_services; l; l = g_list_next(l)) {
+ struct service *service = l->data;
+
+ if (service->proxy == proxy) {
+ local_services = g_list_delete_link(local_services, l);
+ return service;
+ }
+ }
+
+ return NULL;
+}
+
void gatt_remove_service(GDBusProxy *proxy)
{
+ struct service *service;
GList *l;
l = g_list_find(services, proxy);
@@ -212,6 +229,11 @@ void gatt_remove_service(GDBusProxy *proxy)
services = g_list_delete_link(services, l);
print_service_proxy(proxy, COLORED_DEL);
+
+ service = remove_service_by_proxy(proxy);
+ if (service)
+ g_dbus_unregister_interface(service->conn, service->path,
+ SERVICE_INTERFACE);
}
static void print_chrc(struct chrc *chrc, const char *description)