device: arm keep-alive instance when queuing active-connection for activation

Now that the keep-alive instance defaults to ALIVE by default, we can
always arm it when starting to activate the active-connection.

The keep-alive instance may have been armed earlier already:
for example, when binding its lifetime to a D-Bus name or
when watching the connection's visible state.

However, at the moment when we queue the active-connection for
activation, we also want to make sure that the keep-alive instance is
armed. It is nicer for consistancy reasons.

Note, that nm_keep_alive_arm() has no effect if nm_keep_alive_disarm()
was called earlier already. Also note, that NMActiveConnection will
disarm the keep-alive instance, when changing to a state greater than
ACTIVATED. So, all works together nicely.

Also, no longer arm the keep-alive instance in the constructor of
NMActiveConnection. It would essentially mean, that the instances
is aremd very early.

Also, as alternative point of interest, arm the keep-alive instance
when registering the signal handler in "nm-policy.c".
This commit is contained in:
Thomas Haller 2018-11-20 16:01:32 +01:00
parent f59db9bb44
commit a4bdb161eb
3 changed files with 20 additions and 4 deletions

View file

@ -67,6 +67,7 @@
#include "settings/nm-settings.h"
#include "nm-setting-ethtool.h"
#include "nm-auth-utils.h"
#include "nm-keep-alive.h"
#include "nm-netns.h"
#include "nm-dispatcher.h"
#include "nm-config.h"
@ -11870,9 +11871,24 @@ do_fail:
void
nm_device_queue_activation (NMDevice *self, NMActRequest *req)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMDevicePrivate *priv;
gboolean must_queue;
g_return_if_fail (NM_IS_DEVICE (self));
g_return_if_fail (NM_IS_ACT_REQUEST (req));
nm_keep_alive_arm (nm_active_connection_get_keep_alive (NM_ACTIVE_CONNECTION (req)));
if (nm_active_connection_get_state (NM_ACTIVE_CONNECTION (req)) >= NM_ACTIVE_CONNECTION_STATE_DEACTIVATING) {
/* it's already deactivating. Nothing to do. */
nm_assert (NM_IN_SET (nm_active_connection_get_device (NM_ACTIVE_CONNECTION (req)), NULL, self));
return;
}
nm_assert (self == nm_active_connection_get_device (NM_ACTIVE_CONNECTION (req)));
priv = NM_DEVICE_GET_PRIVATE (self);
must_queue = _carrier_wait_check_act_request_must_queue (self, req);
if ( !priv->act_request.obj

View file

@ -1472,10 +1472,8 @@ constructed (GObject *object)
if (NM_IN_SET ((NMActivationReason) priv->activation_reason,
NM_ACTIVATION_REASON_AUTOCONNECT,
NM_ACTIVATION_REASON_AUTOCONNECT_SLAVES)) {
NM_ACTIVATION_REASON_AUTOCONNECT_SLAVES))
nm_keep_alive_set_settings_connection_watch_visible (priv->keep_alive, priv->settings_connection.obj);
nm_keep_alive_arm (priv->keep_alive);
}
}
static void

View file

@ -2237,6 +2237,8 @@ active_connection_added (NMManager *manager,
keep_alive = nm_active_connection_get_keep_alive (active);
nm_keep_alive_arm (keep_alive);
g_signal_connect (active, "notify::" NM_ACTIVE_CONNECTION_STATE,
G_CALLBACK (active_connection_state_changed),
self);