summaryrefslogtreecommitdiff
path: root/src/nm-manager.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-04-22 12:50:42 +0200
committerThomas Haller <thaller@redhat.com>2018-04-30 16:36:29 +0200
commit36ed7ef0845410bd25afd4b3abd86410af02422b (patch)
treea8d7097676fe21318dd53717696fef16fdce9777 /src/nm-manager.c
parent9424aa0562ebcbeaa61588aafcfb1da914c41a75 (diff)
downloadNetworkManager-36ed7ef0845410bd25afd4b3abd86410af02422b.tar.gz
manager: minor refactoring of active_connection_find_by_connection()
active_connection_find_by_connection() (or how it was called previously) is a simpler wrapper around active_connection_find(), which accepts a NMConnection argument, that may or may not be a NMSettingsConnection. It always passed NM_ACTIVE_CONNECTION_STATE_DEACTIVATING as max_state, and I think that one of the two callers don't should do that. A later commit will change that. So, we also want to pass @max_state as argument to active_connection_find_by_connection(). At that point, make active_connection_find_by_connection() identical to active_connection_find(), with the only exception, that it accepts a NMConnection and does automatically do the right thing (either lookup by pointer equality or by uuid).
Diffstat (limited to 'src/nm-manager.c')
-rw-r--r--src/nm-manager.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 1367203207..c8813fce36 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -1004,8 +1004,10 @@ active_connection_find (NMManager *self,
}
static NMActiveConnection *
-active_connection_find_first_by_connection (NMManager *self,
- NMConnection *connection)
+active_connection_find_by_connection (NMManager *self,
+ NMConnection *connection,
+ NMActiveConnectionState max_state,
+ GPtrArray **out_all_matching)
{
gboolean is_settings_connection;
@@ -1018,8 +1020,8 @@ active_connection_find_first_by_connection (NMManager *self,
return active_connection_find (self,
is_settings_connection ? NM_SETTINGS_CONNECTION (connection) : NULL,
is_settings_connection ? NULL : nm_connection_get_uuid (connection),
- NM_ACTIVE_CONNECTION_STATE_DEACTIVATING,
- NULL);
+ max_state,
+ out_all_matching);
}
static gboolean
@@ -3226,7 +3228,7 @@ nm_manager_get_best_device_for_connection (NMManager *self,
NMDevice *device;
NMDeviceCheckConAvailableFlags flags;
- ac = active_connection_find_first_by_connection (self, connection);
+ ac = active_connection_find_by_connection (self, connection, NM_ACTIVE_CONNECTION_STATE_DEACTIVATING, NULL);
if (ac) {
act_device = nm_active_connection_get_device (ac);
if (act_device)
@@ -4211,7 +4213,7 @@ _new_active_connection (NMManager *self,
/* FIXME: for VPN connections, we don't allow re-activating an
* already active connection. It's a bug, and should be fixed together
* when reworking VPN handling. */
- if (active_connection_find_first_by_connection (self, connection)) {
+ if (active_connection_find_by_connection (self, connection, NM_ACTIVE_CONNECTION_STATE_DEACTIVATING, NULL)) {
g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_CONNECTION_ALREADY_ACTIVE,
"Connection '%s' is already active",
nm_connection_get_id (connection));