diff --git a/src/nm-config-data.c b/src/nm-config-data.c index 03d381106..8683696e8 100644 --- a/src/nm-config-data.c +++ b/src/nm-config-data.c @@ -21,6 +21,8 @@ #include "nm-config-data.h" +#include "nm-config.h" + typedef struct { char *config_main_file; char *config_description; @@ -91,6 +93,34 @@ nm_config_data_get_connectivity_response (const NMConfigData *self) } +/************************************************************************/ + +GHashTable * +nm_config_data_diff (NMConfigData *old_data, NMConfigData *new_data) +{ + GHashTable *changes; + + g_return_val_if_fail (NM_IS_CONFIG_DATA (old_data), NULL); + g_return_val_if_fail (NM_IS_CONFIG_DATA (new_data), NULL); + + changes = g_hash_table_new (g_str_hash, g_str_equal); + + if ( g_strcmp0 (nm_config_data_get_config_main_file (old_data), nm_config_data_get_config_main_file (new_data)) != 0 + || g_strcmp0 (nm_config_data_get_config_description (old_data), nm_config_data_get_config_description (new_data)) != 0) + g_hash_table_insert (changes, NM_CONFIG_CHANGES_CONFIG_FILES, NULL); + + if ( nm_config_data_get_connectivity_interval (old_data) != nm_config_data_get_connectivity_interval (new_data) + || g_strcmp0 (nm_config_data_get_connectivity_uri (old_data), nm_config_data_get_connectivity_uri (new_data)) + || g_strcmp0 (nm_config_data_get_connectivity_response (old_data), nm_config_data_get_connectivity_response (new_data))) + g_hash_table_insert (changes, NM_CONFIG_CHANGES_CONNECTIVITY, NULL); + + if (!g_hash_table_size (changes)) { + g_hash_table_destroy (changes); + return NULL; + } + return changes; +} + /************************************************************************/ static void diff --git a/src/nm-config-data.h b/src/nm-config-data.h index c690f08b9..cd6313cdf 100644 --- a/src/nm-config-data.h +++ b/src/nm-config-data.h @@ -56,6 +56,8 @@ NMConfigData *nm_config_data_new (const char *config_main_file, const char *config_description, GKeyFile *keyfile); +GHashTable *nm_config_data_diff (NMConfigData *old_data, NMConfigData *new_data); + const char *nm_config_data_get_config_main_file (const NMConfigData *config_data); const char *nm_config_data_get_config_description (const NMConfigData *config_data); diff --git a/src/nm-config.c b/src/nm-config.c index 6fb733513..0eb3c08b7 100644 --- a/src/nm-config.c +++ b/src/nm-config.c @@ -721,28 +721,10 @@ nm_config_reload (NMConfig *self) g_free (config_description); g_key_file_free (keyfile); - - changes = g_hash_table_new (g_str_hash, g_str_equal); - - /* reloading configuration means we have to carefully check every single option - * that we want to support and take specific actions. */ - old_data = priv->config_data; - if ( nm_config_data_get_connectivity_interval (old_data) != nm_config_data_get_connectivity_interval (new_data) - || g_strcmp0 (nm_config_data_get_connectivity_uri (old_data), nm_config_data_get_connectivity_uri (new_data)) - || g_strcmp0 (nm_config_data_get_connectivity_response (old_data), nm_config_data_get_connectivity_response (new_data))) { - nm_log_dbg (LOGD_CORE, "config: reload: change '" NM_CONFIG_CHANGES_CONNECTIVITY "'"); - g_hash_table_insert (changes, NM_CONFIG_CHANGES_CONNECTIVITY, NULL); - } + changes = nm_config_data_diff (old_data, new_data); - if ( g_strcmp0 (nm_config_data_get_config_main_file (old_data), nm_config_data_get_config_main_file (new_data)) != 0 - || g_strcmp0 (nm_config_data_get_config_description (old_data), nm_config_data_get_config_description (new_data)) != 0) { - nm_log_dbg (LOGD_CORE, "config: reload: change '" NM_CONFIG_CHANGES_CONFIG_FILES "'"); - g_hash_table_insert (changes, NM_CONFIG_CHANGES_CONFIG_FILES, NULL); - } - - if (!g_hash_table_size (changes)) { - g_hash_table_destroy (changes); + if (!changes) { g_object_unref (new_data); return; }