summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-02-19 14:24:37 +0100
committerThomas Haller <thaller@redhat.com>2015-05-19 15:34:41 +0200
commit652853e0d0749a12db07e34f1a3cd901020a76f8 (patch)
tree472944be957df996540de53c3e20a60b2b996663
parent5b04fde302a7264a7d361043bfcdde7855341727 (diff)
downloadNetworkManager-652853e0d0749a12db07e34f1a3cd901020a76f8.tar.gz
connectivity: use default on missing connectivity.interval config
Manual page claims that a missing configuration option for connectivity interval means "300". That was not the case for a long time (never?). https://bugzilla.gnome.org/show_bug.cgi?id=723350 Based-on-patch-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
-rw-r--r--src/nm-config-data.c12
-rw-r--r--src/nm-config.h2
-rw-r--r--src/nm-connectivity.c3
3 files changed, 13 insertions, 4 deletions
diff --git a/src/nm-config-data.c b/src/nm-config-data.c
index f624862a6d..2142670ba5 100644
--- a/src/nm-config-data.c
+++ b/src/nm-config-data.c
@@ -26,6 +26,7 @@
#include "nm-config.h"
#include "gsystem-local-alloc.h"
#include "nm-device.h"
+#include "nm-core-internal.h"
typedef struct {
char *config_main_file;
@@ -343,13 +344,18 @@ constructed (GObject *object)
{
NMConfigData *self = NM_CONFIG_DATA (object);
NMConfigDataPrivate *priv = NM_CONFIG_DATA_GET_PRIVATE (self);
- int interval;
+ char *interval;
priv->connectivity.uri = g_key_file_get_value (priv->keyfile, "connectivity", "uri", NULL);
priv->connectivity.response = g_key_file_get_value (priv->keyfile, "connectivity", "response", NULL);
- interval = g_key_file_get_integer (priv->keyfile, "connectivity", "interval", NULL);
- priv->connectivity.interval = MAX (0, interval);
+ /* On missing config value, fallback to 300. On invalid value, disable connectivity checking by setting
+ * the interval to zero. */
+ interval = g_key_file_get_value (priv->keyfile, "connectivity", "interval", NULL);
+ priv->connectivity.interval = interval
+ ? _nm_utils_ascii_str_to_int64 (interval, 10, 0, G_MAXUINT, 0)
+ : NM_CONFIG_DEFAULT_CONNECTIVITY_INTERVAL;
+ g_free (interval);
priv->dns_mode = g_key_file_get_value (priv->keyfile, "main", "dns", NULL);
priv->rc_manager = g_key_file_get_value (priv->keyfile, "main", "rc-manager", NULL);
diff --git a/src/nm-config.h b/src/nm-config.h
index ecd083a62c..e72132af9d 100644
--- a/src/nm-config.h
+++ b/src/nm-config.h
@@ -43,6 +43,8 @@ G_BEGIN_DECLS
/* Signals */
#define NM_CONFIG_SIGNAL_CONFIG_CHANGED "config-changed"
+#define NM_CONFIG_DEFAULT_CONNECTIVITY_INTERVAL 300
+
typedef struct NMConfigCmdLineOptions NMConfigCmdLineOptions;
struct _NMConfig {
diff --git a/src/nm-connectivity.c b/src/nm-connectivity.c
index ecb9c0f5c1..1dfcf00b15 100644
--- a/src/nm-connectivity.c
+++ b/src/nm-connectivity.c
@@ -27,6 +27,7 @@
#endif
#include "nm-connectivity.h"
+#include "nm-config.h"
#include "nm-logging.h"
G_DEFINE_TYPE (NMConnectivity, nm_connectivity, G_TYPE_OBJECT)
@@ -499,7 +500,7 @@ nm_connectivity_class_init (NMConnectivityClass *klass)
g_object_class_install_property
(object_class, PROP_INTERVAL,
g_param_spec_uint (NM_CONNECTIVITY_INTERVAL, "", "",
- 0, G_MAXUINT, 300,
+ 0, G_MAXUINT, NM_CONFIG_DEFAULT_CONNECTIVITY_INTERVAL,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));