[PATCH 20/32] Release health link resources

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 health/hdp.c |   27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/health/hdp.c b/health/hdp.c
index 234109a..4ed0150 100644
--- a/health/hdp.c
+++ b/health/hdp.c
@@ -359,10 +359,32 @@ static uint8_t hdp_mcap_mdl_reconn_req_cb(struct mcap_mcl *mcl,
 	return MCAP_REQUEST_NOT_SUPPORTED;
 }
 
+static void health_link_free(struct hdp_link *hdpl)
+{
+	/*TODO: Release structures related with Data Channels */
+
+	if (hdpl->mcl) {
+		mcap_close_mcl(hdpl->mcl, FALSE);
+		mcap_mcl_unref(hdpl->mcl);
+		hdpl->mcl = NULL;
+	}
+
+	if (hdpl->path) {
+		g_free(hdpl->path);
+		hdpl->path = NULL;
+	}
+
+	hdpl->hdpi->hlink = g_slist_remove(hdpl->hdpi->hlink, hdpl);
+	g_free(hdpl);
+}
+
 static void health_link_path_unregister(void *data)
 {
-	/* struct hdp_link *hdpl = data */
-	/* TODO: Unregister hdp_link*/
+	struct hdp_link *hdpl = data;
+
+	DBG("Unregistered interface %s on path %s", HEALTH_LINK, hdpl->path);
+
+	health_link_free(hdpl);
 }
 
 static GDBusMethodTable health_link_methods[] = {
@@ -399,7 +421,6 @@ static struct hdp_link *create_health_link(struct hdp_instance *hdpi,
 	g_set_error(err, HDP_ERROR, HDP_UNSPECIFIED_ERROR,
 				"Cant register the health link in the bus");
 
-	/* TODO create a function to free health link correctly */
 	/* MCAP will close the MCL and won't cache it if we didn't
 	* increase the MCL reference counter during the callback. */
 	mcap_mcl_unref(hdpl->mcl);
-- 
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux