From: Daniel Wagner <[email protected]>
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 8aebd53..bf965d2 100644
--- a/plugins/session_policy_local.c
+++ b/plugins/session_policy_local.c
@@ -286,6 +286,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);
@@ -308,8 +310,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",
@@ -317,20 +317,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++) {
@@ -342,9 +340,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);
@@ -429,7 +424,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;
}
@@ -447,7 +441,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.2.rc3.16.gce432ca
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman