core: use GSource for tracking reset_connections_retries idle action
The numeric source IDs are discouraged. Use a GSource instead.
This commit is contained in:
@@ -64,6 +64,8 @@ typedef struct {
|
|||||||
|
|
||||||
GSource *device_recheck_auto_activate_all_idle_source;
|
GSource *device_recheck_auto_activate_all_idle_source;
|
||||||
|
|
||||||
|
GSource *reset_connections_retries_idle_source;
|
||||||
|
|
||||||
NMHostnameManager *hostname_manager;
|
NMHostnameManager *hostname_manager;
|
||||||
|
|
||||||
NMActiveConnection *default_ac4, *activating_ac4;
|
NMActiveConnection *default_ac4, *activating_ac4;
|
||||||
@@ -72,8 +74,6 @@ typedef struct {
|
|||||||
NMDnsManager *dns_manager;
|
NMDnsManager *dns_manager;
|
||||||
gulong config_changed_id;
|
gulong config_changed_id;
|
||||||
|
|
||||||
guint reset_retries_id; /* idle handler for resetting the retries count */
|
|
||||||
|
|
||||||
NMPolicyHostnameMode hostname_mode;
|
NMPolicyHostnameMode hostname_mode;
|
||||||
char *orig_hostname; /* hostname at NM start time */
|
char *orig_hostname; /* hostname at NM start time */
|
||||||
char *cur_hostname; /* hostname we want to assign */
|
char *cur_hostname; /* hostname we want to assign */
|
||||||
@@ -1720,7 +1720,7 @@ reset_connections_retries(gpointer user_data)
|
|||||||
gint32 con_stamp, min_stamp, now;
|
gint32 con_stamp, min_stamp, now;
|
||||||
gboolean changed = FALSE;
|
gboolean changed = FALSE;
|
||||||
|
|
||||||
priv->reset_retries_id = 0;
|
nm_clear_g_source_inst(&priv->reset_connections_retries_idle_source);
|
||||||
|
|
||||||
min_stamp = 0;
|
min_stamp = 0;
|
||||||
now = nm_utils_get_monotonic_timestamp_sec();
|
now = nm_utils_get_monotonic_timestamp_sec();
|
||||||
@@ -1741,15 +1741,16 @@ reset_connections_retries(gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Schedule the handler again if there are some stamps left */
|
/* Schedule the handler again if there are some stamps left */
|
||||||
if (min_stamp != 0)
|
if (min_stamp != 0) {
|
||||||
priv->reset_retries_id =
|
priv->reset_connections_retries_idle_source =
|
||||||
g_timeout_add_seconds(min_stamp - now, reset_connections_retries, self);
|
nm_g_timeout_add_seconds_source(min_stamp - now, reset_connections_retries, self);
|
||||||
|
}
|
||||||
|
|
||||||
/* If anything changed, try to activate the newly re-enabled connections */
|
/* If anything changed, try to activate the newly re-enabled connections */
|
||||||
if (changed)
|
if (changed)
|
||||||
nm_policy_device_recheck_auto_activate_all_schedule(self);
|
nm_policy_device_recheck_auto_activate_all_schedule(self);
|
||||||
|
|
||||||
return FALSE;
|
return G_SOURCE_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1766,14 +1767,14 @@ _connection_autoconnect_retries_set(NMPolicy *self,
|
|||||||
|
|
||||||
if (tries == 0) {
|
if (tries == 0) {
|
||||||
/* Schedule a handler to reset retries count */
|
/* Schedule a handler to reset retries count */
|
||||||
if (!priv->reset_retries_id) {
|
if (!priv->reset_connections_retries_idle_source) {
|
||||||
gint32 retry_time = nm_manager_devcon_autoconnect_retries_blocked_until(priv->manager,
|
gint32 retry_time = nm_manager_devcon_autoconnect_retries_blocked_until(priv->manager,
|
||||||
device,
|
device,
|
||||||
connection);
|
connection);
|
||||||
|
|
||||||
g_warn_if_fail(retry_time != 0);
|
g_warn_if_fail(retry_time != 0);
|
||||||
priv->reset_retries_id =
|
priv->reset_connections_retries_idle_source = nm_g_timeout_add_seconds_source(
|
||||||
g_timeout_add_seconds(MAX(0, retry_time - nm_utils_get_monotonic_timestamp_sec()),
|
MAX(0, retry_time - nm_utils_get_monotonic_timestamp_sec()),
|
||||||
reset_connections_retries,
|
reset_connections_retries,
|
||||||
self);
|
self);
|
||||||
}
|
}
|
||||||
@@ -2938,7 +2939,7 @@ dispose(GObject *object)
|
|||||||
*/
|
*/
|
||||||
nm_assert(c_list_is_empty(nm_manager_get_active_connections(priv->manager)));
|
nm_assert(c_list_is_empty(nm_manager_get_active_connections(priv->manager)));
|
||||||
|
|
||||||
nm_clear_g_source(&priv->reset_retries_id);
|
nm_clear_g_source_inst(&priv->reset_connections_retries_idle_source);
|
||||||
nm_clear_g_source_inst(&priv->device_recheck_auto_activate_all_idle_source);
|
nm_clear_g_source_inst(&priv->device_recheck_auto_activate_all_idle_source);
|
||||||
|
|
||||||
nm_clear_g_free(&priv->orig_hostname);
|
nm_clear_g_free(&priv->orig_hostname);
|
||||||
|
Reference in New Issue
Block a user