Let the core handle the children unregister task
authorMarcel Holtmann <marcel@holtmann.org>
Sun, 10 Aug 2008 09:58:32 +0000 (11:58 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Sun, 10 Aug 2008 09:58:32 +0000 (11:58 +0200)
plugins/ethernet.c

index b908940..0f248bc 100644 (file)
@@ -38,9 +38,6 @@
 static GStaticMutex ethernet_mutex = G_STATIC_MUTEX_INIT;
 static GSList *ethernet_list = NULL;
 
-static GStaticMutex element_mutex = G_STATIC_MUTEX_INIT;
-static GSList *element_list = NULL;
-
 static void create_element(struct connman_element *parent,
                                        enum connman_element_type type)
 {
@@ -54,42 +51,9 @@ static void create_element(struct connman_element *parent,
        element->netdev.index = parent->netdev.index;
        element->netdev.name = g_strdup(parent->netdev.name);
 
-       g_static_mutex_lock(&element_mutex);
-       element_list = g_slist_append(element_list, element);
-       g_static_mutex_unlock(&element_mutex);
-
        connman_element_register(element, parent);
 }
 
-static void remove_elements(struct connman_element *parent)
-{
-       GSList *list = element_list;
-
-       DBG("parent %p name %s", parent, parent->name);
-
-       g_static_mutex_lock(&element_mutex);
-
-       while (list) {
-               GSList *next = list->next;
-               struct connman_element *element = list->data;
-
-               if (element->netdev.index != parent->netdev.index) {
-                       list = next;
-                       continue;
-               }
-
-               element_list = g_slist_delete_link(element_list, list);
-
-               connman_element_unregister(element);
-
-               connman_element_unref(element);
-
-               list = next;
-       }
-
-       g_static_mutex_unlock(&element_mutex);
-}
-
 static void rtnl_link(struct nlmsghdr *hdr, const char *type)
 {
        GSList *list;
@@ -127,7 +91,7 @@ static void rtnl_link(struct nlmsghdr *hdr, const char *type)
                } else {
                        DBG("carrier off");
 
-                       remove_elements(element);
+                       connman_element_unregister_children(element);
                }
        }
 
@@ -327,8 +291,6 @@ static void ethernet_remove(struct connman_element *element)
 
        iface_down(element);
 
-       remove_elements(element);
-
        g_static_mutex_lock(&ethernet_mutex);
        ethernet_list = g_slist_remove(ethernet_list, element);
        g_static_mutex_unlock(&ethernet_mutex);