[PATCH v3 15/21] agent: Release all agents when stopping

Jukka Rissanen jukka.rissanen at linux.intel.com
Fri Nov 30 01:30:48 PST 2012


---
 src/agent.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/agent.c b/src/agent.c
index a1eab1f..c08dba8 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -409,14 +409,20 @@ void connman_agent_driver_unregister(struct connman_agent_driver *driver)
 {
 	GSList *list;
 
+	if (driver == NULL)
+		return;
+
 	DBG("Unregistering driver %p name %s", driver, driver->name);
 
 	for (list = driver_list; list; list = list->next) {
 		DBusMessage *message;
 
-		if (driver == list->data)
+		if (driver != list->data)
 			continue;
 
+		DBG("Sending release to %s path %s iface %s", agent_sender,
+			agent_path, driver->interface);
+
 		message = dbus_message_new_method_call(agent_sender, agent_path,
 				driver->interface, "Release");
 		if (message != NULL) {
@@ -425,11 +431,23 @@ void connman_agent_driver_unregister(struct connman_agent_driver *driver)
 		}
 
 		agent_free();
+
+		/*
+		 * ATM agent_free() unsets the agent_sender and agent_path
+		 * variables so we can unregister only once.
+		 * This needs proper fix later.
+		 */
+		break;
 	}
 
 	driver_list = g_slist_remove(driver_list, driver);
 }
 
+static void release_all_agents(void)
+{
+	connman_agent_driver_unregister(get_driver());
+}
+
 int __connman_agent_init(void)
 {
 	DBG("");
@@ -451,6 +469,8 @@ void __connman_agent_cleanup(void)
 	if (agent_watch > 0)
 		g_dbus_remove_watch(connection, agent_watch);
 
+	release_all_agents();
+
 	dbus_connection_unref(connection);
 	connection = NULL;
 }
-- 
1.7.11.4




More information about the connman mailing list