From: Daniel Wagner <[email protected]>
We want to make the lifetime of the policy data structure independent
of the policy_hash table.
---
plugins/session_policy_local.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/plugins/session_policy_local.c b/plugins/session_policy_local.c
index ad79e66..823f76a 100644
--- a/plugins/session_policy_local.c
+++ b/plugins/session_policy_local.c
@@ -48,6 +48,7 @@ static DBusConnection *connection;
static GHashTable *policy_hash;
static GHashTable *session_hash;
+static GSList *policy_list;
struct create_data {
struct connman_session *session;
@@ -61,7 +62,7 @@ struct policy_data {
struct connman_session_config *config;
};
-static void cleanup_policy(gpointer user_data)
+static void free_policy(gpointer user_data)
{
struct policy_data *policy = user_data;
@@ -123,6 +124,8 @@ static struct policy_data *create_policy(const char *ident)
policy->config = connman_session_create_default_config();
policy->ident = g_strdup(ident);
+ policy_list = g_slist_prepend(policy_list, policy);
+
g_hash_table_replace(policy_hash, policy->ident, policy);
return policy;
@@ -144,7 +147,11 @@ static void policy_unref(struct policy_data *policy)
if (__sync_fetch_and_sub(&policy->refcount, 1) != 1)
return;
+ policy_list = g_slist_remove(policy_list, policy);
+
g_hash_table_remove(policy_hash, policy->ident);
+
+ free_policy(policy);
};
static void selinux_context_reply(int error,
@@ -480,7 +487,7 @@ static int session_policy_local_init(void)
session_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal,
NULL, NULL);
policy_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
- NULL, cleanup_policy);
+ NULL, NULL);
err = connman_inotify_register(POLICYDIR, notify_handler);
if (err < 0)
@@ -518,6 +525,8 @@ static void session_policy_local_exit(void)
g_hash_table_destroy(session_hash);
g_hash_table_destroy(policy_hash);
+ g_slist_free_full(policy_list, free_policy);
+
connman_session_policy_unregister(&session_policy_local);
dbus_connection_unref(connection);
--
1.8.2.rc3.16.gce432ca
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman