mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-06 06:10:14 +01:00
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).
This commit is contained in:
parent
9424aa0562
commit
36ed7ef084
1 changed files with 8 additions and 6 deletions
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue