diff options
author | Alfonso Sánchez-Beato <alfonso.sanchez-beato@canonical.com> | 2020-05-15 12:38:40 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-06-03 18:29:12 +0200 |
commit | fcfc12d50fb566bfa46abc64788aaecf3ce464f2 (patch) | |
tree | 4d6d4f8e479b53d8e78bdce7d1542d5500d0d377 | |
parent | 6022af99635fa1c0f89426ab13821d47a82db189 (diff) | |
download | NetworkManager-fcfc12d50fb566bfa46abc64788aaecf3ce464f2.tar.gz |
settings: move up autoconnect initialization functions
Move autoconnect initialization functions up so we can use them from
update_auth_cb.
-rw-r--r-- | src/settings/nm-settings-connection.c | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c index c6348cb492..37a4025863 100644 --- a/src/settings/nm-settings-connection.c +++ b/src/settings/nm-settings-connection.c @@ -1409,6 +1409,54 @@ update_complete (NMSettingsConnection *self, g_slice_free (UpdateInfo, info); } +static int +_autoconnect_retries_initial (NMSettingsConnection *self) +{ + NMSettingConnection *s_con; + int retries = -1; + + s_con = nm_connection_get_setting_connection (nm_settings_connection_get_connection (self)); + if (s_con) + retries = nm_setting_connection_get_autoconnect_retries (s_con); + + /* -1 means 'default' */ + if (retries == -1) + retries = nm_config_data_get_autoconnect_retries_default (NM_CONFIG_GET_DATA); + + /* 0 means 'forever', which is translated to a retry count of -1 */ + if (retries == 0) + retries = AUTOCONNECT_RETRIES_FOREVER; + + nm_assert (retries == AUTOCONNECT_RETRIES_FOREVER || retries >= 0); + return retries; +} + +static void +_autoconnect_retries_set (NMSettingsConnection *self, + int retries, + gboolean is_reset) +{ + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); + + g_return_if_fail (retries == AUTOCONNECT_RETRIES_FOREVER || retries >= 0); + + if (priv->autoconnect_retries != retries) { + _LOGT ("autoconnect: retries set %d%s", retries, + is_reset ? " (reset)" : ""); + priv->autoconnect_retries = retries; + } + + if (retries) + priv->autoconnect_retries_blocked_until = 0; + else { + /* NOTE: the blocked time must be identical for all connections, otherwise + * the tracking of resetting the retry count in NMPolicy needs adjustment + * in _connection_autoconnect_retries_set() (as it would need to re-evaluate + * the next-timeout every time a connection gets blocked). */ + priv->autoconnect_retries_blocked_until = nm_utils_get_monotonic_timestamp_sec () + AUTOCONNECT_RESET_RETRIES_TIMER; + } +} + static void update_auth_cb (NMSettingsConnection *self, GDBusMethodInvocation *context, @@ -2328,54 +2376,6 @@ nm_settings_connection_add_seen_bssid (NMSettingsConnection *self, /*****************************************************************************/ -static int -_autoconnect_retries_initial (NMSettingsConnection *self) -{ - NMSettingConnection *s_con; - int retries = -1; - - s_con = nm_connection_get_setting_connection (nm_settings_connection_get_connection (self)); - if (s_con) - retries = nm_setting_connection_get_autoconnect_retries (s_con); - - /* -1 means 'default' */ - if (retries == -1) - retries = nm_config_data_get_autoconnect_retries_default (NM_CONFIG_GET_DATA); - - /* 0 means 'forever', which is translated to a retry count of -1 */ - if (retries == 0) - retries = AUTOCONNECT_RETRIES_FOREVER; - - nm_assert (retries == AUTOCONNECT_RETRIES_FOREVER || retries >= 0); - return retries; -} - -static void -_autoconnect_retries_set (NMSettingsConnection *self, - int retries, - gboolean is_reset) -{ - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); - - g_return_if_fail (retries == AUTOCONNECT_RETRIES_FOREVER || retries >= 0); - - if (priv->autoconnect_retries != retries) { - _LOGT ("autoconnect: retries set %d%s", retries, - is_reset ? " (reset)" : ""); - priv->autoconnect_retries = retries; - } - - if (retries) - priv->autoconnect_retries_blocked_until = 0; - else { - /* NOTE: the blocked time must be identical for all connections, otherwise - * the tracking of resetting the retry count in NMPolicy needs adjustment - * in _connection_autoconnect_retries_set() (as it would need to re-evaluate - * the next-timeout every time a connection gets blocked). */ - priv->autoconnect_retries_blocked_until = nm_utils_get_monotonic_timestamp_sec () + AUTOCONNECT_RESET_RETRIES_TIMER; - } -} - /** * nm_settings_connection_autoconnect_retries_get: * @self: the settings connection |