Commit 652853e0 authored by Thomas Haller's avatar Thomas Haller

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=723350Based-on-patch-by: Mathieu Trudel-Lapierre's avatarMathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
parent 5b04fde3
......@@ -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);
......
......@@ -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 {
......
......@@ -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));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment