From 38dd17caa900b553302ee9ba92575d96bc31bfb1 Mon Sep 17 00:00:00 2001 From: "hyunuk.tak" Date: Wed, 16 Oct 2019 10:02:44 +0900 Subject: [PATCH] Destroy profile handle when all connection handle is deinitialized Change-Id: I79b0ef91e9dd5c6cce5007747219a4f994d7e120 Signed-off-by: hyunuk.tak --- include/net_connection_private.h | 2 +- src/connection.c | 2 +- src/libnetwork.c | 20 +++++++++++--------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/include/net_connection_private.h b/include/net_connection_private.h index 1af2a6e..0550e32 100755 --- a/include/net_connection_private.h +++ b/include/net_connection_private.h @@ -136,7 +136,7 @@ typedef struct _connection_handle_s { } connection_handle_s; int _connection_libnet_init(connection_handle_s *conn_handle); -bool _connection_libnet_deinit(connection_handle_s *conn_handle); +bool _connection_libnet_deinit(connection_handle_s *conn_handle, bool is_empty); void _connection_set_cs_tid(int tid, connection_handle_s *conn_handle); void _connection_unset_cs_tid(int tid, connection_handle_s *conn_handle); int _connection_libnet_get_metered_state(connection_handle_s *conn_handle, bool* is_metered); diff --git a/src/connection.c b/src/connection.c index b90606f..9cc447f 100755 --- a/src/connection.c +++ b/src/connection.c @@ -202,9 +202,9 @@ EXPORT_API int connection_destroy(connection_h connection) __connection_set_proxy_changed_callback(connection, NULL, NULL); __connection_set_internet_state_changed_callback(connection, NULL, NULL); __connection_set_ethernet_cable_state_changed_cb(connection, NULL, NULL); - _connection_libnet_deinit(connection); conn_handle_list = g_slist_remove(conn_handle_list, connection); + _connection_libnet_deinit(connection, (conn_handle_list == NULL)); g_free(connection); connection = NULL; diff --git a/src/libnetwork.c b/src/libnetwork.c index 2d60d7c..5100cb7 100755 --- a/src/libnetwork.c +++ b/src/libnetwork.c @@ -486,20 +486,22 @@ int _connection_libnet_init(connection_handle_s *conn_handle) return NET_ERR_NONE; } -bool _connection_libnet_deinit(connection_handle_s *conn_handle) +bool _connection_libnet_deinit(connection_handle_s *conn_handle, bool is_empty) { net_deregister_client(conn_handle->network_info_handle); - if (profile_cb_table) { - g_hash_table_destroy(profile_cb_table); - profile_cb_table = NULL; - } + if (is_empty) { + if (profile_cb_table) { + g_hash_table_destroy(profile_cb_table); + profile_cb_table = NULL; + } - __libnet_clear_profile_list(&profile_iterator); + __libnet_clear_profile_list(&profile_iterator); - if (prof_handle_list) { - g_slist_free_full(prof_handle_list, g_free); - prof_handle_list = NULL; + if (prof_handle_list) { + g_slist_free_full(prof_handle_list, g_free); + prof_handle_list = NULL; + } } return true; -- 2.7.4