From: Daniel Wagner <daniel.wag...@bmw-carit.de>

When we open the policy file and try to parse we might run
into an error. Instead of freeing the policy we just need
to reset it to the defaults and then try to apply the new settings.
We should reallyt not unref the policy on the error case because
the policy lifetime is attached to the lifetime of the file not
on the result of the parsing.
---
 plugins/session_policy_local.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/plugins/session_policy_local.c b/plugins/session_policy_local.c
index 1658412..d65da82 100644
--- a/plugins/session_policy_local.c
+++ b/plugins/session_policy_local.c
@@ -398,6 +398,8 @@ static int load_policy(struct policy_data *policy)
        char *str, **tokens;
        int i, err = 0;
 
+       connman_session_set_default_config(config);
+
        pathname = g_strdup_printf("%s/%s", POLICYDIR, policy->filename);
 
        err = load_keyfile(pathname, &keyfile);
@@ -420,8 +422,6 @@ static int load_policy(struct policy_data *policy)
        if (str != NULL) {
                config->roaming_policy = 
connman_session_parse_roaming_policy(str);
                g_free(str);
-       } else {
-               config->roaming_policy = CONNMAN_SESSION_ROAMING_POLICY_DEFAULT;
        }
 
        str = g_key_file_get_string(keyfile, "Default", "ConnectionType",
@@ -429,20 +429,18 @@ static int load_policy(struct policy_data *policy)
        if (str != NULL) {
                config->type = connman_session_parse_connection_type(str);
                g_free(str);
-       } else {
-               config->type = CONNMAN_SESSION_TYPE_ANY;
        }
 
        config->ecall = g_key_file_get_boolean(keyfile, "Default",
                                                "EmergencyCall", NULL);
 
-       g_slist_free(config->allowed_bearers);
-       config->allowed_bearers = NULL;
-
        str = g_key_file_get_string(keyfile, "Default", "AllowedBearers",
                                NULL);
 
        if (str != NULL) {
+               g_slist_free(config->allowed_bearers);
+               config->allowed_bearers = NULL;
+
                tokens = g_strsplit(str, " ", 0);
 
                for (i = 0; tokens[i] != NULL; i++) {
@@ -454,9 +452,6 @@ static int load_policy(struct policy_data *policy)
 
                g_free(str);
                g_strfreev(tokens);
-       } else {
-               config->allowed_bearers = g_slist_append(NULL,
-                               GINT_TO_POINTER(CONNMAN_SERVICE_TYPE_UNKNOWN));
        }
 
        g_key_file_free(keyfile);
@@ -525,7 +520,6 @@ static void notify_handler(struct inotify_event *event,
                if (err < 0) {
                        connman_warn("Loading policy file '%s' failed with %s",
                                        filename, strerror(-err));
-                       policy_unref(policy);
                        return;
                }
 
@@ -543,7 +537,6 @@ static void notify_handler(struct inotify_event *event,
                if (err < 0) {
                        connman_warn("Loading policy file '%s' failed with %s",
                                        filename, strerror(-err));
-                       remove_policy(policy);
                        return;
                }
        }
-- 
1.8.1.3.566.gaa39828

_______________________________________________
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

Reply via email to