diff options
author | Dan Williams <dcbw@redhat.com> | 2014-03-20 11:22:19 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2014-03-20 19:26:40 -0500 |
commit | e4bcfc20ca6de7a39506a2eda050fa144e3cc52c (patch) | |
tree | b8bd0cba419ac58b352c9c1c268b61536250f880 | |
parent | 398080640e70d8177a93ee94c4662194c08397cd (diff) | |
download | NetworkManager-e4bcfc20ca6de7a39506a2eda050fa144e3cc52c.tar.gz |
core: export ActiveConnection before handing it to the device (bgo #723783)
The AC doesn't get a D-Bus path until it's exported, but that happens after
it's handed to the Device it will be activated on. The Device emits a
PropertyChanged event when it's handed the AC, but it ignores ACs that
aren't exported yet. Thus when activating, the Device doesn't emit the
AC's path at all in the ActiveConnection property because it's NULL.
Fix that by exporting the AC immediately before starting activation
with it.
Second, move the notification of the Device.ActiveConnection property
to be emitted along with the state change to PREPARE instead of long
before it. While we don't guarantee signal ordering in general, this
seems like a more correct ordering.
https://bugzilla.gnome.org/show_bug.cgi?id=723783
-rw-r--r-- | src/devices/nm-device.c | 7 | ||||
-rw-r--r-- | src/nm-manager.c | 20 |
2 files changed, 19 insertions, 8 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 51c08acb31..ea5f3affec 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -2168,6 +2168,9 @@ nm_device_activate_stage1_device_prepare (gpointer user_data) priv->ip4_state = priv->ip6_state = IP_NONE; + /* Notify the new ActiveConnection along with the state change */ + g_object_notify (G_OBJECT (self), NM_DEVICE_ACTIVE_CONNECTION); + iface = nm_device_get_iface (self); nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 1 of 5 (Device Prepare) started...", iface); nm_device_state_changed (self, NM_DEVICE_STATE_PREPARE, NM_DEVICE_STATE_REASON_NONE); @@ -4938,8 +4941,10 @@ _device_activate (NMDevice *self, NMActRequest *req) NM_DEVICE_STATE_REASON_NOW_MANAGED); } + /* note: don't notify D-Bus of the new AC here, but do it later when + * changing state to PREPARE so that the two properties change together. + */ priv->act_request = g_object_ref (req); - g_object_notify (G_OBJECT (self), NM_DEVICE_ACTIVE_CONNECTION); nm_device_activate_schedule_stage1_device_prepare (self); } diff --git a/src/nm-manager.c b/src/nm-manager.c index 51d11ced36..be2f11846a 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -2597,11 +2597,18 @@ ensure_master_active_connection (NMManager *self, static gboolean _internal_activate_vpn (NMManager *self, NMActiveConnection *active, GError **error) { + gboolean success; + g_assert (NM_IS_VPN_CONNECTION (active)); - return nm_vpn_manager_activate_connection (NM_MANAGER_GET_PRIVATE (self)->vpn_manager, - NM_VPN_CONNECTION (active), - error); + success = nm_vpn_manager_activate_connection (NM_MANAGER_GET_PRIVATE (self)->vpn_manager, + NM_VPN_CONNECTION (active), + error); + if (success) { + nm_active_connection_export (active); + g_object_notify (G_OBJECT (self), NM_MANAGER_ACTIVE_CONNECTIONS); + } + return success; } static gboolean @@ -2732,7 +2739,9 @@ _internal_activate_device (NMManager *self, NMActiveConnection *active, GError * nm_active_connection_get_path (master_ac)); } - /* Start the new activation */ + /* Export the new ActiveConnection to clients and start it on the device */ + nm_active_connection_export (active); + g_object_notify (G_OBJECT (self), NM_MANAGER_ACTIVE_CONNECTIONS); nm_device_queue_activation (device, NM_ACT_REQUEST (active)); return TRUE; } @@ -2760,9 +2769,6 @@ _internal_activate_generic (NMManager *self, NMActiveConnection *active, GError success = _internal_activate_device (self, active, error); if (success) { - nm_active_connection_export (active); - g_object_notify (G_OBJECT (self), NM_MANAGER_ACTIVE_CONNECTIONS); - /* Force an update of the Manager's activating-connection property. * The device changes state before the AC gets exported, which causes * the manager's 'activating-connection' property to be NULL since the |