[network-manager-netbook] Make sure to not add duplicate Ethernet connections.
- From: Tambet Ingo <tambeti src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [network-manager-netbook] Make sure to not add duplicate Ethernet connections.
- Date: Thu, 24 Sep 2009 11:56:54 +0000 (UTC)
commit f79eec06c3151f197e9c7c91cbcfa12fb4f37d15
Author: Tambet Ingo <tambet gmail com>
Date: Thu Sep 24 12:20:50 2009 +0300
Make sure to not add duplicate Ethernet connections.
There's a race condition that sometimes we get two signals (carrier changed,
device state changed) and as a result, add two items for one ethernet device/
exported connection combo.
src/nmn-ethernet-handler.c | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/src/nmn-ethernet-handler.c b/src/nmn-ethernet-handler.c
index 7a77e60..d8430c7 100644
--- a/src/nmn-ethernet-handler.c
+++ b/src/nmn-ethernet-handler.c
@@ -47,6 +47,22 @@ nmn_ethernet_handler_new (NmnNMData *nm_data,
NULL));
}
+static gboolean
+have_item_for_connection (NmnDeviceHandler *handler,
+ NMExportedConnection *exported)
+{
+ GSList *list;
+ GSList *iter;
+
+ list = nmn_device_handler_get_items (handler);
+ for (iter = list; iter; iter = iter->next) {
+ if (nmn_network_item_get_connection (NMN_NETWORK_ITEM (iter->data)) == exported)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static void
connection_added (NmnDeviceHandler *handler,
NMExportedConnection *exported)
@@ -60,7 +76,8 @@ connection_added (NmnDeviceHandler *handler,
return;
wrapped = nm_exported_connection_get_connection (exported);
- if (utils_connection_valid_for_device (wrapped, NM_DEVICE (device), NULL)) {
+ if (utils_connection_valid_for_device (wrapped, NM_DEVICE (device), NULL) &&
+ !have_item_for_connection (handler, exported)) {
item = nmn_ethernet_item_new (nmn_device_handler_get_nm_data (handler), device);
g_object_set (item, NMN_NETWORK_ITEM_CONNECTION, exported, NULL);
nmn_device_handler_add_item (handler, NMN_NETWORK_ITEM (item));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]