summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-01-07 14:30:14 +0100
committerThomas Haller <thaller@redhat.com>2015-02-03 13:01:53 +0100
commit045a576a7ab8dac3f7aa9302532fa94e790c1f05 (patch)
treee444d9ef8bbeb7fc8655f72b978bed5490028872
parent56f5fba72353e55db554c359af00376d3959009d (diff)
downloadNetworkManager-045a576a7ab8dac3f7aa9302532fa94e790c1f05.tar.gz
config: add new function nm_config_data_diff()
-rw-r--r--src/nm-config-data.c30
-rw-r--r--src/nm-config-data.h2
-rw-r--r--src/nm-config.c22
3 files changed, 34 insertions, 20 deletions
diff --git a/src/nm-config-data.c b/src/nm-config-data.c
index 03d3811065..8683696e81 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;
@@ -93,6 +95,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
get_property (GObject *object,
guint prop_id,
diff --git a/src/nm-config-data.h b/src/nm-config-data.h
index c690f08b97..cd6313cdf7 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 6fb7335133..0eb3c08b7c 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);
- }
-
- 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);
- }
+ changes = nm_config_data_diff (old_data, new_data);
- if (!g_hash_table_size (changes)) {
- g_hash_table_destroy (changes);
+ if (!changes) {
g_object_unref (new_data);
return;
}