summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>2015-05-19 15:44:14 +0200
committerThomas Haller <thaller@redhat.com>2015-05-19 15:52:34 +0200
commit24e9b904279ddf6107ffde2609db5565cda5ffb5 (patch)
treedef60158df61b7fd9deb884cc95ab04f8ed41418
parent47c505523c72b6454dec4681c0edda535c3a2e91 (diff)
downloadNetworkManager-nm-0-9-8.tar.gz
connectivity: explicitly set the default interval for connectivity checkingnm-0-9-8
This matches what is documented in the man page; 300 seconds as the default value for the connectivity checking interval if it's not set in the config file or passed as a command-line parameter. This is already fixed on master by 652853e0d0749a12db07e34f1a3cd901020a76f8. https://bugzilla.gnome.org/show_bug.cgi?id=723350 [thaller@redhat.com: I modified the original patch]
-rw-r--r--src/nm-config.c16
-rw-r--r--src/nm-config.h2
-rw-r--r--src/nm-connectivity.c3
3 files changed, 18 insertions, 3 deletions
diff --git a/src/nm-config.c b/src/nm-config.c
index 6e801d353f..6e40f482dc 100644
--- a/src/nm-config.c
+++ b/src/nm-config.c
@@ -140,6 +140,8 @@ fill_from_file (NMConfig *config,
{
GKeyFile *kf;
gboolean success = FALSE;
+ int value;
+ GError *local = NULL;
if (g_file_test (path, G_FILE_TEST_EXISTS) == FALSE) {
g_set_error (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_NOT_FOUND, "file %s not found", path);
@@ -183,8 +185,18 @@ fill_from_file (NMConfig *config,
if (cli_connectivity_interval >= 0)
config->connectivity_interval = cli_connectivity_interval;
- else
- config->connectivity_interval = g_key_file_get_integer (kf, "connectivity", "interval", NULL);
+ else {
+ value = g_key_file_get_integer (kf, "connectivity", "interval", &local);
+ if (!local)
+ config->connectivity_interval = MAX (0, value);
+ else {
+ /* Using a default value here, which isn't a problem if connectivity
+ * isn't set up, as uri would be NULL.
+ */
+ config->connectivity_interval = NM_CONFIG_DEFAULT_CONNECTIVITY_INTERVAL;
+ g_clear_error (&local);
+ }
+ }
if (cli_connectivity_response && strlen (cli_connectivity_response))
config->connectivity_response = g_strdup (cli_connectivity_response);
diff --git a/src/nm-config.h b/src/nm-config.h
index 6c4206c132..8fd3f08f78 100644
--- a/src/nm-config.h
+++ b/src/nm-config.h
@@ -24,6 +24,8 @@
#include <glib.h>
#include <glib-object.h>
+#define NM_CONFIG_DEFAULT_CONNECTIVITY_INTERVAL 300
+
typedef struct NMConfig NMConfig;
typedef enum {
diff --git a/src/nm-connectivity.c b/src/nm-connectivity.c
index 7e3bed9978..83b4808fc3 100644
--- a/src/nm-connectivity.c
+++ b/src/nm-connectivity.c
@@ -29,6 +29,7 @@
#include "nm-connectivity.h"
#include "nm-logging.h"
#include "nm-manager.h"
+#include "nm-config.h"
G_DEFINE_TYPE (NMConnectivity, nm_connectivity, G_TYPE_OBJECT)
@@ -390,7 +391,7 @@ nm_connectivity_class_init (NMConnectivityClass *klass)
g_param_spec_uint (NM_CONNECTIVITY_INTERVAL,
"Interval",
"Connectivity check interval in seconds",
- 0, G_MAXUINT, 300,
+ 0, G_MAXUINT, NM_CONFIG_DEFAULT_CONNECTIVITY_INTERVAL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property