From 74e2a49df7c7c61b91b3cbc6273c5b49d8603f74 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sat, 11 Oct 2008 09:24:54 +0200 Subject: [PATCH] Change device removal handling --- plugins/hal.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/hal.c b/plugins/hal.c index bda2f8c..12d67ef 100644 --- a/plugins/hal.c +++ b/plugins/hal.c @@ -168,6 +168,7 @@ static void device_added(LibHalContext *ctx, const char *udi) static void device_removed(LibHalContext *ctx, const char *udi) { + struct connman_element *removal = NULL; GSList *list; gchar *name; @@ -181,14 +182,18 @@ static void device_removed(LibHalContext *ctx, const char *udi) struct connman_element *element = list->data; if (g_str_equal(element->name, name) == TRUE) { - element_list = g_slist_remove(element_list, element); - - connman_element_unregister(element); - connman_element_unref(element); + removal = element; break; } } + if (removal != NULL) { + element_list = g_slist_remove(element_list, removal); + + connman_element_unregister(removal); + connman_element_unref(removal); + } + g_static_mutex_unlock(&element_mutex); g_free(name); -- 2.7.4