diff options
author | Daniel Wagner <daniel.wagner@bmw-carit.de> | 2012-12-05 14:57:48 +0100 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-12-05 16:50:59 +0200 |
commit | 8008dace850e867ce39b120fc9ba5ffd860e5c94 (patch) | |
tree | e18b3100473b477eb37d3163504bb3794a7984a6 /src/session.c | |
parent | 0b47fc58a28c3d8275d7ed473966ae03a3b023b2 (diff) | |
download | connman-8008dace850e867ce39b120fc9ba5ffd860e5c94.tar.gz connman-8008dace850e867ce39b120fc9ba5ffd860e5c94.tar.bz2 connman-8008dace850e867ce39b120fc9ba5ffd860e5c94.zip |
session: Move cleanup/destroy function up
We need to call those function from create_policy_config() therefore
more it in front of it.
Diffstat (limited to 'src/session.c')
-rw-r--r-- | src/session.c | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/src/session.c b/src/session.c index fa6a0e96..076eb809 100644 --- a/src/session.c +++ b/src/session.c @@ -236,6 +236,54 @@ static char *service2bearer(enum connman_service_type type) return ""; } +static void destroy_policy_config(struct connman_session *session) +{ + if (session->policy == NULL) { + g_free(session->policy_config); + return; + } + + (*session->policy->destroy)(session); +} + +static void free_session(struct connman_session *session) +{ + if (session == NULL) + return; + + if (session->notify_watch > 0) + g_dbus_remove_watch(connection, session->notify_watch); + + destroy_policy_config(session); + g_slist_free(session->info->config.allowed_bearers); + g_free(session->owner); + g_free(session->session_path); + g_free(session->notify_path); + g_free(session->info); + g_free(session->info_last); + + g_free(session); +} + +static void cleanup_session(gpointer user_data) +{ + struct connman_session *session = user_data; + struct session_info *info = session->info; + + DBG("remove %s", session->session_path); + + g_slist_free(session->user_allowed_bearers); + g_hash_table_destroy(session->service_hash); + g_sequence_free(session->service_list); + + if (info->entry != NULL && + info->entry->reason == CONNMAN_SESSION_REASON_CONNECT) { + __connman_service_disconnect(info->entry->service); + } + + free_session(session); +} + static int assign_policy_plugin(struct connman_session *session) { if (session->policy != NULL) @@ -268,16 +316,6 @@ static int create_policy_config(struct connman_session *session, return (*session->policy->create)(session, callback, user_data); } -static void destroy_policy_config(struct connman_session *session) -{ - if (session->policy == NULL) { - g_free(session->policy_config); - return; - } - - (*session->policy->destroy)(session); -} - static void probe_policy(struct connman_session_policy *policy) { @@ -860,44 +898,6 @@ static gint sort_services(gconstpointer a, gconstpointer b, gpointer user_data) session); } -static void free_session(struct connman_session *session) -{ - if (session == NULL) - return; - - if (session->notify_watch > 0) - g_dbus_remove_watch(connection, session->notify_watch); - - destroy_policy_config(session); - g_slist_free(session->info->config.allowed_bearers); - g_free(session->owner); - g_free(session->session_path); - g_free(session->notify_path); - g_free(session->info); - g_free(session->info_last); - - g_free(session); -} - -static void cleanup_session(gpointer user_data) -{ - struct connman_session *session = user_data; - struct session_info *info = session->info; - - DBG("remove %s", session->session_path); - - g_slist_free(session->user_allowed_bearers); - g_hash_table_destroy(session->service_hash); - g_sequence_free(session->service_list); - - if (info->entry != NULL && - info->entry->reason == CONNMAN_SESSION_REASON_CONNECT) { - __connman_service_disconnect(info->entry->service); - } - - free_session(session); -} - static enum connman_session_state service_to_session_state(enum connman_service_state state) { switch (state) { |