From 75d694db9b7db389904430eaaee4cfe3f9d592e9 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 14 Nov 2013 10:00:35 -0600 Subject: [PATCH] core: optimize generated connection matching a bit Do a quick check to see if the connetion is compatible with the device before we start doing a relatively heavy connection comparison. --- src/nm-manager.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/nm-manager.c b/src/nm-manager.c index 3a8ad15a66..aa7f918ba2 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -1755,18 +1755,22 @@ get_existing_connection (NMManager *manager, NMDevice *device) for (iter = connections; iter; iter = iter->next) { NMConnection *candidate = NM_CONNECTION (iter->data); - if (nm_connection_compare (connection, candidate, NM_SETTING_COMPARE_FLAG_INFERRABLE)) { - nm_log_info (LOGD_DEVICE, "(%s): found matching connection '%s'", - nm_device_get_iface (device), - nm_connection_get_id (candidate)); - g_object_unref (connection); - return candidate; - } + if (!nm_device_check_connection_compatible (device, candidate, NULL)) + continue; + + if (!nm_connection_compare (connection, candidate, NM_SETTING_COMPARE_FLAG_INFERRABLE)) + continue; + + nm_log_info (LOGD_DEVICE, "(%s): found matching connection '%s'", + nm_device_get_iface (device), + nm_connection_get_id (candidate)); + g_object_unref (connection); + return candidate; } nm_log_dbg (LOGD_DEVICE, "(%s): generated connection '%s'", - nm_device_get_iface (device), - nm_connection_get_id (connection)); + nm_device_get_iface (device), + nm_connection_get_id (connection)); added = nm_settings_add_connection (priv->settings, connection, FALSE, &error); if (!added) {