summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2008-10-21 11:11:43 +0000
committerDan Williams <dcbw@redhat.com>2008-10-21 11:11:43 +0000
commit0c8a2000cb4d6bab7900e518c4d2645eb754602c (patch)
tree173ffc7cd252e235cd4d566527dafcd7aef6f6e1 /src
parent92e5e520190baedee3cc4f9a2d79c96468b9ecf5 (diff)
downloadNetworkManager-0c8a2000cb4d6bab7900e518c4d2645eb754602c.tar.gz
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 git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4200 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
Diffstat (limited to 'src')
-rw-r--r--src/nm-manager.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 8596337b30..74345b0d53 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -732,6 +732,7 @@ typedef struct GetSettingsInfo {
DBusGProxyCall *call;
DBusGProxy *secrets_proxy;
GSList **calls;
+ NMConnectionScope scope;
} GetSettingsInfo;
static void
@@ -747,10 +748,7 @@ free_get_settings_info (gpointer data)
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 @@ connection_get_settings_cb (DBusGProxy *proxy,
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 @@ connection_get_settings_cb (DBusGProxy *proxy,
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 @@ connection_get_settings_cb (DBusGProxy *proxy,
}
/* 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 @@ internal_new_connection_cb (DBusGProxy *proxy,
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,