From a019d965f72e1f8d59413f2df9e8d94cdfff84db Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 28 Apr 2023 11:47:20 +0200 Subject: [PATCH] core: avoid creating devcon data that we don't need MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise, we create device × profiles entries, most of them nonsensical. --- src/core/nm-manager.c | 11 +++++++++-- src/core/nm-policy.c | 10 ++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c index 46adfd356b..6d8245c7d8 100644 --- a/src/core/nm-manager.c +++ b/src/core/nm-manager.c @@ -1456,7 +1456,11 @@ nm_manager_devcon_autoconnect_retries_blocked_until(NMManager *self, nm_assert(NM_IS_SETTINGS_CONNECTION(sett_conn)); if (device) { - data = _devcon_lookup_data(self, device, sett_conn, TRUE, TRUE); + data = _devcon_lookup_data(self, device, sett_conn, FALSE, FALSE); + + if (!data) + return 0; + return data->autoconnect.blocked_until_sec; } @@ -1487,7 +1491,10 @@ nm_manager_devcon_autoconnect_is_blocked(NMManager *self, if (nm_settings_connection_autoconnect_is_blocked(sett_conn)) return TRUE; - data = _devcon_lookup_data(self, device, sett_conn, TRUE, TRUE); + data = _devcon_lookup_data(self, device, sett_conn, FALSE, FALSE); + + if (!data) + return FALSE; if (data->autoconnect.blocked_reason != NM_SETTINGS_AUTOCONNECT_BLOCKED_REASON_NONE) return TRUE; diff --git a/src/core/nm-policy.c b/src/core/nm-policy.c index ae2c15f22a..7a4cab1d21 100644 --- a/src/core/nm-policy.c +++ b/src/core/nm-policy.c @@ -1758,11 +1758,13 @@ _connection_autoconnect_retries_set(NMPolicy *self, if (tries == 0) { /* Schedule a handler to reset retries count */ if (!priv->reset_connections_retries_idle_source) { - gint32 retry_time = nm_manager_devcon_autoconnect_retries_blocked_until(priv->manager, - device, - connection); + gint32 retry_time; + + retry_time = nm_manager_devcon_autoconnect_retries_blocked_until(priv->manager, + device, + connection); + nm_assert(retry_time != 0); - g_warn_if_fail(retry_time != 0); priv->reset_connections_retries_idle_source = nm_g_timeout_add_seconds_source( MAX(0, retry_time - nm_utils_get_monotonic_timestamp_sec()), reset_connections_retries,