diff mbox series

[1/1] mesh: Add mesh agent cleanup to mesh cleanup

Message ID 1585078044-14974-1-git-send-email-prathyusha.n@samsung.com (mailing list archive)
State Superseded
Delegated to: Brian Gix
Headers show
Series [1/1] mesh: Add mesh agent cleanup to mesh cleanup | expand

Commit Message

Prathyusha Nelluri March 24, 2020, 7:27 p.m. UTC
From: Prathyusha N <prathyusha.n@samsung.com>

Freed agent completely in agent_free(). Removed agent from queue
after app disconnects in provisioner case. Linked agent to
join_pending so that agent gets freed after every join call.
Added mesh_agent_cleanup in mesh_cleanup to clear and free
agents queue.
---
 mesh/agent.c   | 3 ++-
 mesh/manager.c | 1 +
 mesh/mesh.c    | 2 ++
 3 files changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/mesh/agent.c b/mesh/agent.c
index 3ab3893a1..ec49c37d0 100644
--- a/mesh/agent.c
+++ b/mesh/agent.c
@@ -205,6 +205,7 @@  static void agent_free(void *agent_data)
 
 	l_free(agent->path);
 	l_free(agent->owner);
+	l_free(agent);
 }
 
 void mesh_agent_remove(struct mesh_agent *agent)
@@ -212,8 +213,8 @@  void mesh_agent_remove(struct mesh_agent *agent)
 	if (!agent || !l_queue_find(agents, simple_match, agent))
 		return;
 
-	agent_free(agent);
 	l_queue_remove(agents, agent);
+	agent_free(agent);
 }
 
 void mesh_agent_cleanup(void)
diff --git a/mesh/manager.c b/mesh/manager.c
index e4a7deaeb..0b6511b4a 100644
--- a/mesh/manager.c
+++ b/mesh/manager.c
@@ -92,6 +92,7 @@  static void prov_disc_cb(struct l_dbus *bus, void *user_data)
 	initiator_cancel(add_pending);
 	add_pending->disc_watch = 0;
 
+	mesh_agent_remove(add_pending->agent);
 	free_pending_add_call();
 }
 
diff --git a/mesh/mesh.c b/mesh/mesh.c
index 6d2f86b6d..caabab508 100644
--- a/mesh/mesh.c
+++ b/mesh/mesh.c
@@ -336,6 +336,7 @@  void mesh_cleanup(void)
 	l_queue_destroy(pending_queue, pending_request_exit);
 	node_cleanup_all();
 	mesh_model_cleanup();
+	mesh_agent_cleanup();
 
 	l_dbus_object_remove_interface(dbus_get_bus(), BLUEZ_MESH_PATH,
 							MESH_NETWORK_INTERFACE);
@@ -480,6 +481,7 @@  static void node_init_cb(struct mesh_node *node, struct mesh_agent *agent)
 	}
 
 	join_pending->node = node;
+	join_pending->agent = agent;
 	num_ele = node_get_num_elements(node);
 
 	if (!acceptor_start(num_ele, join_pending->uuid, mesh.algorithms,