NetworkManager r4200 - in trunk: . src



Author: dcbw
Date: Tue Oct 21 11:11:43 2008
New Revision: 4200
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=4200&view=rev

Log:
2008-10-21  Dan Williams  <dcbw redhat com>

	* src/nm-manager.c
		- (free_get_settings_info): don't use the DBusGProxy which could be
			disposed of by the time the function is called
		- (internal_new_connection_cb): save connection scope
		- (connection_get_settings_cb): don't replace a connection unless it's
			actually different from the existing one; fixes an issue where
			killing the settings service wouldn't deactivate an active connection
			provided by that settings service, because it was using a connection
			that had already been replaced in the system or user hash



Modified:
   trunk/ChangeLog
   trunk/src/nm-manager.c

Modified: trunk/src/nm-manager.c
==============================================================================
--- trunk/src/nm-manager.c	(original)
+++ trunk/src/nm-manager.c	Tue Oct 21 11:11:43 2008
@@ -732,6 +732,7 @@
 	DBusGProxyCall *call;
 	DBusGProxy *secrets_proxy;
 	GSList **calls;
+	NMConnectionScope scope;
 } GetSettingsInfo;
 
 static void
@@ -747,10 +748,7 @@
 		if (g_slist_length (*(info->calls)) == 0) {
 			g_slist_free (*(info->calls));
 			g_slice_free (GSList, (gpointer) info->calls);
-			g_signal_emit (info->manager,
-			               signals[CONNECTIONS_ADDED],
-			               0,
-			               get_scope_for_proxy (info->proxy));
+			g_signal_emit (info->manager, signals[CONNECTIONS_ADDED], 0, info->scope);
 		}
 	}
 
@@ -794,6 +792,7 @@
 		const char *path = dbus_g_proxy_get_path (proxy);
 		NMManagerPrivate *priv;
 		GError *error = NULL;
+		NMConnection *existing = NULL;
 
 		connection = nm_connection_new_from_hash (settings, &error);
 		if (connection == NULL) {
@@ -820,17 +819,32 @@
 		                        info->secrets_proxy,
 		                        (GDestroyNotify) g_object_unref);
 
+		/* Add the new connection to the internal hashes only if the same
+		 * connection isn't already there.
+		 */
 		priv = NM_MANAGER_GET_PRIVATE (manager);
 		switch (scope) {
 			case NM_CONNECTION_SCOPE_USER:
-				g_hash_table_insert (priv->user_connections,
-				                     g_strdup (path),
-				                     connection);
+				existing = g_hash_table_lookup (priv->user_connections, path);
+				if (!existing || !nm_connection_compare (existing, connection, COMPARE_FLAGS_EXACT)) {
+					g_hash_table_insert (priv->user_connections,
+					                     g_strdup (path),
+					                     connection);
+					existing = NULL;
+				} else {
+					g_object_unref (connection);
+				}
 				break;
 			case NM_CONNECTION_SCOPE_SYSTEM:
-				g_hash_table_insert (priv->system_connections,
-				                     g_strdup (path),
-				                     connection);
+				existing = g_hash_table_lookup (priv->system_connections, path);
+				if (!existing || !nm_connection_compare (existing, connection, COMPARE_FLAGS_EXACT)) {
+					g_hash_table_insert (priv->system_connections,
+					                     g_strdup (path),
+					                     connection);
+					existing = NULL;
+				} else {
+					g_object_unref (connection);
+				}
 				break;
 			default:
 				nm_warning ("Connection wasn't a user connection or a system connection.");
@@ -839,9 +853,10 @@
 		}
 
 		/* If the connection-added signal is supposed to be batched, don't
-		 * emit the single connection-added here.
+		 * emit the single connection-added here.  Also, don't emit the signal
+		 * if the connection wasn't actually added to the system or user hashes.
 		 */
-		if (!info->calls)
+		if (!info->calls && !existing)
 			g_signal_emit (manager, signals[CONNECTION_ADDED], 0, connection, scope);
 	} else {
 		// FIXME: merge settings? or just replace?
@@ -996,6 +1011,7 @@
 	info = g_slice_new0 (GetSettingsInfo);
 	info->manager = g_object_ref (manager);
 	info->calls = calls;
+	info->scope = get_scope_for_proxy (con_proxy);
 	call = dbus_g_proxy_begin_call (con_proxy, "GetSettings",
 	                                connection_get_settings_cb,
 	                                info,



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