[PATCH v1] session_polici_ivi: Fix initialization order

Daniel Wagner wagi at monom.org
Thu Nov 29 06:03:11 PST 2012


From: Daniel Wagner <daniel.wagner at bmw-carit.de>

We need to initialize the resources before registering the notify
and policy handlers.
---
 plugins/session_policy_ivi.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/plugins/session_policy_ivi.c b/plugins/session_policy_ivi.c
index e107c03..9820c74 100644
--- a/plugins/session_policy_ivi.c
+++ b/plugins/session_policy_ivi.c
@@ -468,20 +468,10 @@ static int session_policy_ivi_init(void)
 {
 	int err;
 
-	err = connman_inotify_register(POLICYDIR, notify_handler);
-	if (err < 0)
-		return err;
-
 	connection = connman_dbus_get_connection();
 	if (connection == NULL)
 		return -EIO;
 
-	err = connman_session_policy_register(&session_policy_ivi);
-	if (err < 0) {
-		dbus_connection_unref(connection);
-		return err;
-	}
-
 	session_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal,
 						NULL, NULL);
 	if (session_hash == NULL) {
@@ -496,12 +486,24 @@ static int session_policy_ivi_init(void)
 		goto err;
 	}
 
-	err = read_policies();
+	err = connman_inotify_register(POLICYDIR, notify_handler);
 	if (err < 0)
 		goto err;
 
+	err = read_policies();
+	if (err < 0)
+		goto err_notify;
+
+	err = connman_session_policy_register(&session_policy_ivi);
+	if (err < 0)
+		goto err_notify;
+
 	return 0;
 
+err_notify:
+
+	connman_inotify_unregister(POLICYDIR, notify_handler);
+
 err:
 	if (session_hash != NULL)
 		g_hash_table_destroy(session_hash);
@@ -512,8 +514,6 @@ err:
 
 	dbus_connection_unref(connection);
 
-	connman_inotify_unregister(POLICYDIR, notify_handler);
-
 	return err;
 }
 
-- 
1.8.0.rc0




More information about the connman mailing list