[PATCH 0.9.8] core: emit Manager ActiveConnections before Device ActiveConnection



When activating a connection, the Device object's ActiveConnection
property was emitted before the object was added to the Manager's
active connection list, and thus before the Manager emitted a
change signal for the ActiveConnections property.  That's the
opposite order from what it should be; the manager should know
about the AC before the device starts using it.
---
 src/nm-manager.c | 58 +++++++++++++++++++++++++-------------------------------
 1 file changed, 26 insertions(+), 32 deletions(-)

diff --git a/src/nm-manager.c b/src/nm-manager.c
index 2cd210b..653dd4f 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -2004,17 +2004,15 @@ add_device (NMManager *self, NMDevice *device)
                NMActiveConnection *ac;
                GError *error = NULL;
 
                nm_log_dbg (LOGD_DEVICE, "(%s): will attempt to assume existing connection",
                            nm_device_get_iface (device));
 
                ac = internal_activate_device (self, device, existing, NULL, FALSE, 0, NULL, TRUE, NULL, 
&error);
-               if (ac)
-                       active_connection_add (self, ac);
-               else {
+               if (!ac) {
                        nm_log_warn (LOGD_DEVICE, "assumed connection %s failed to activate: (%d) %s",
                                     nm_connection_get_path (existing),
                                     error ? error->code : -1,
                                     error && error->message ? error->message : "(unknown)");
                        g_error_free (error);
                }
        }
@@ -2515,14 +2513,15 @@ internal_activate_device (NMManager *manager,
                                  user_requested,
                                  sender_uid,
                                  dbus_sender,
                                  assumed,
                                  device,
                                  master_device);
        g_assert (req);
+       active_connection_add (manager, NM_ACTIVE_CONNECTION (req));
        nm_device_activate (device, req);
 
        return NM_ACTIVE_CONNECTION (req);
 }
 
 /**
  * find_master:
@@ -2792,15 +2791,15 @@ static NMActiveConnection *
 activate_vpn_connection (NMManager *self,
                          NMConnection *connection,
                          const char *specific_object,
                          gulong sender_uid,
                          GError **error)
 {
        NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
-       NMActiveConnection *parent = NULL;
+       NMActiveConnection *parent = NULL, *ac;
        NMDevice *device = NULL;
        GSList *iter;
 
        if (specific_object) {
                /* Find the specifc connection the client requested we use */
                parent = active_connection_get_by_path (self, specific_object);
                if (!parent) {
@@ -2828,21 +2827,24 @@ activate_vpn_connection (NMManager *self,
        device = nm_active_connection_get_device (parent);
        if (!device) {
                g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_DEVICE,
                                     "Source connection had no active device.");
                return NULL;
        }
 
-       return nm_vpn_manager_activate_connection (priv->vpn_manager,
-                                                  connection,
-                                                  device,
-                                                  nm_active_connection_get_path (parent),
-                                                  TRUE,
-                                                  sender_uid,
-                                                  error);
+       ac = nm_vpn_manager_activate_connection (priv->vpn_manager,
+                                                connection,
+                                                device,
+                                                nm_active_connection_get_path (parent),
+                                                TRUE,
+                                                sender_uid,
+                                                error);
+       if (ac)
+               active_connection_add (self, ac);
+       return ac;
 }
 
 NMActiveConnection *
 nm_manager_activate_connection (NMManager *manager,
                                 NMConnection *connection,
                                 const char *specific_object,
                                 const char *device_path,
@@ -2853,15 +2855,15 @@ nm_manager_activate_connection (NMManager *manager,
        NMDevice *device = NULL;
        gulong sender_uid = 0;
        DBusError dbus_error;
        NMDeviceState state;
        char *iface;
        NMDevice *master_device = NULL;
        NMConnection *master_connection = NULL;
-       NMActiveConnection *master_ac = NULL, *ac = NULL;
+       NMActiveConnection *master_ac = NULL;
        gboolean matched;
 
        g_return_val_if_fail (manager != NULL, NULL);
        g_return_val_if_fail (connection != NULL, NULL);
        g_return_val_if_fail (error != NULL, NULL);
        g_return_val_if_fail (*error == NULL, NULL);
 
@@ -2879,18 +2881,16 @@ nm_manager_activate_connection (NMManager *manager,
                                             "Failed to get unix user for dbus sender");
                        dbus_error_free (&dbus_error);
                        return NULL;
                }
        }
 
        /* VPN ? */
-       if (nm_connection_is_type (connection, NM_SETTING_VPN_SETTING_NAME)) {
-               ac = activate_vpn_connection (manager, connection, specific_object, sender_uid, error);
-               goto activated;
-       }
+       if (nm_connection_is_type (connection, NM_SETTING_VPN_SETTING_NAME))
+               return activate_vpn_connection (manager, connection, specific_object, sender_uid, error);
 
        /* Device-based connection */
        if (device_path) {
                device = nm_manager_get_device_by_path (manager, device_path);
                if (!device) {
                        g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_DEVICE,
                                             "Device not found");
@@ -3019,30 +3019,24 @@ nm_manager_activate_connection (NMManager *manager,
                }
 
                nm_log_dbg (LOGD_CORE, "Activation of '%s' depends on active connection %s",
                            nm_connection_get_id (connection),
                            nm_active_connection_get_path (master_ac));
        }
 
-       ac = internal_activate_device (manager,
-                                      device,
-                                      connection,
-                                      specific_object,
-                                      dbus_sender ? TRUE : FALSE,
-                                      dbus_sender ? sender_uid : 0,
-                                      dbus_sender,
-                                      FALSE,
-                                      master_ac,
-                                      error);
-
-activated:
-       if (ac)
-               active_connection_add (manager, ac);
-
-       return ac;
+       return internal_activate_device (manager,
+                                        device,
+                                        connection,
+                                        specific_object,
+                                        dbus_sender ? TRUE : FALSE,
+                                        dbus_sender ? sender_uid : 0,
+                                        dbus_sender,
+                                        FALSE,
+                                        master_ac,
+                                        error);
 }
 
 /* 
  * TODO this function was created and named in the era of user settings, where
  * we could get activation requests for a connection before we got the settings
  * data of that connection. Now that user settings are gone, flatten or rename
  * it.
-- 
1.8.5.3




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]