mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-04-21 21:40:45 +02:00
core: move deactivation of active connections to the manager
It's needed for the next commit.
This commit is contained in:
parent
9d4bbf78f0
commit
e6b3a6a2b6
3 changed files with 30 additions and 30 deletions
|
|
@ -5978,6 +5978,33 @@ fail:
|
|||
error_desc ?: error->message);
|
||||
}
|
||||
|
||||
void
|
||||
nm_manager_deactivate_ac(NMManager *self, NMSettingsConnection *connection)
|
||||
{
|
||||
NMActiveConnection *ac;
|
||||
const CList *tmp_list, *tmp_safe;
|
||||
GError *error = NULL;
|
||||
|
||||
nm_assert(NM_IS_SETTINGS_CONNECTION(connection));
|
||||
|
||||
nm_manager_for_each_active_connection_safe (self, ac, tmp_list, tmp_safe) {
|
||||
if (nm_active_connection_get_settings_connection(ac) == connection
|
||||
&& (nm_active_connection_get_state(ac) <= NM_ACTIVE_CONNECTION_STATE_ACTIVATED)) {
|
||||
if (!nm_manager_deactivate_connection(self,
|
||||
ac,
|
||||
NM_DEVICE_STATE_REASON_CONNECTION_REMOVED,
|
||||
&error)) {
|
||||
_LOGW(LOGD_DEVICE,
|
||||
"connection '%s' disappeared, but error deactivating it: (%d) %s",
|
||||
nm_settings_connection_get_id(connection),
|
||||
error ? error->code : -1,
|
||||
error ? error->message : "(unknown)");
|
||||
g_clear_error(&error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_manager_activate_connection():
|
||||
* @self: the #NMManager
|
||||
|
|
|
|||
|
|
@ -121,6 +121,8 @@ NMSettingsConnection **nm_manager_get_activatable_connections(NMManager *manager
|
|||
gboolean sort,
|
||||
guint *out_len);
|
||||
|
||||
void nm_manager_deactivate_ac(NMManager *self, NMSettingsConnection *connection);
|
||||
|
||||
void nm_manager_write_device_state_all(NMManager *manager);
|
||||
gboolean nm_manager_write_device_state(NMManager *manager, NMDevice *device, int *out_ifindex);
|
||||
|
||||
|
|
|
|||
|
|
@ -2624,41 +2624,12 @@ connection_updated(NMSettings *settings,
|
|||
schedule_activate_all(self);
|
||||
}
|
||||
|
||||
static void
|
||||
_deactivate_if_active(NMPolicy *self, NMSettingsConnection *connection)
|
||||
{
|
||||
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self);
|
||||
NMActiveConnection *ac;
|
||||
const CList *tmp_list, *tmp_safe;
|
||||
GError *error = NULL;
|
||||
|
||||
nm_assert(NM_IS_SETTINGS_CONNECTION(connection));
|
||||
|
||||
nm_manager_for_each_active_connection_safe (priv->manager, ac, tmp_list, tmp_safe) {
|
||||
if (nm_active_connection_get_settings_connection(ac) == connection
|
||||
&& (nm_active_connection_get_state(ac) <= NM_ACTIVE_CONNECTION_STATE_ACTIVATED)) {
|
||||
if (!nm_manager_deactivate_connection(priv->manager,
|
||||
ac,
|
||||
NM_DEVICE_STATE_REASON_CONNECTION_REMOVED,
|
||||
&error)) {
|
||||
_LOGW(LOGD_DEVICE,
|
||||
"connection '%s' disappeared, but error deactivating it: (%d) %s",
|
||||
nm_settings_connection_get_id(connection),
|
||||
error ? error->code : -1,
|
||||
error ? error->message : "(unknown)");
|
||||
g_clear_error(&error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
connection_removed(NMSettings *settings, NMSettingsConnection *connection, gpointer user_data)
|
||||
{
|
||||
NMPolicyPrivate *priv = user_data;
|
||||
NMPolicy *self = _PRIV_TO_SELF(priv);
|
||||
|
||||
_deactivate_if_active(self, connection);
|
||||
nm_manager_deactivate_ac(priv->manager, connection);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue