From 6c96f5f7776b7c5a86512be3fd2ea24d61e4c6a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Fri, 29 Nov 2013 14:59:48 +0100 Subject: manager: fix connection auto-activation in timestamp-based order (rh #1029854) This commit fixes a regression from a1f16cd4d9fff66d7feeee0846e554c9c3a5f998 (nm-policy.c change). https://bugzilla.redhat.com/show_bug.cgi?id=1029854 --- src/nm-manager.c | 8 +++++++- src/settings/nm-settings.c | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/nm-manager.c b/src/nm-manager.c index adb8d72185..77b042c2a0 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -429,6 +429,12 @@ find_ac_for_connection (NMManager *manager, NMConnection *connection) return NULL; } +/* Filter out connections that are already active. + * nm_settings_get_connections() returns sorted list. We need to preserve the + * order so that we didn't change auto-activation order (recent timestamps + * are first). + * Caller is responsible for freeing the returned list with g_slist_free(). + */ GSList * nm_manager_get_activatable_connections (NMManager *manager) { @@ -445,7 +451,7 @@ nm_manager_get_activatable_connections (NMManager *manager) } g_slist_free (all_connections); - return connections; + return g_slist_reverse (connections); } static NMActiveConnection * diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index be413f8759..c08ccfb744 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -331,8 +331,10 @@ connection_sort (gconstpointer pa, gconstpointer pb) return 1; } -/* Returns a list of NMSettingsConnections. Caller must free the list with - * g_slist_free(). +/* Returns a list of NMSettingsConnections. + * The list is sorted in the order suitable for auto-connecting, i.e. + * first go connections with autoconnect=yes and most recent timestamp. + * Caller must free the list with g_slist_free(). */ GSList * nm_settings_get_connections (NMSettings *self) -- cgit v1.2.1