* [PATCH] dbus: Don't call l_hashmap_remove within l_hashmap_foreach
@ 2016-05-09 9:24 Andrew Zaborowski
2016-05-09 14:23 ` Denis Kenzior
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Zaborowski @ 2016-05-09 9:24 UTC (permalink / raw)
To: ell
[-- Attachment #1: Type: text/plain, Size: 1487 bytes --]
---
ell/dbus-name-cache.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/ell/dbus-name-cache.c b/ell/dbus-name-cache.c
index 6d723d7..24ca619 100644
--- a/ell/dbus-name-cache.c
+++ b/ell/dbus-name-cache.c
@@ -232,9 +232,8 @@ unsigned int _dbus_name_cache_add_watch(struct _dbus_name_cache *cache,
return watch->id;
}
-static void service_watch_remove(const void *key, void *value, void *user_data)
+static bool service_watch_remove(const void *key, void *value, void *user_data)
{
- struct _dbus_name_cache *cache = user_data;
struct name_cache_entry *entry = value;
struct service_watch **watch, *tmp;
@@ -249,8 +248,15 @@ static void service_watch_remove(const void *key, void *value, void *user_data)
service_watch_destroy(tmp);
- _dbus_name_cache_remove(cache, key);
+ entry->ref_count--;
}
+
+ if (entry->ref_count)
+ return false;
+
+ name_cache_entry_destroy(entry);
+
+ return true;
}
static void service_watch_remove_all(struct l_idle *idle, void *user_data)
@@ -260,7 +266,7 @@ static void service_watch_remove_all(struct l_idle *idle, void *user_data)
l_idle_remove(cache->watch_remove_work);
cache->watch_remove_work = NULL;
- l_hashmap_foreach(cache->names, service_watch_remove, cache);
+ l_hashmap_foreach_remove(cache->names, service_watch_remove, cache);
}
static void service_watch_mark(const void *key, void *value, void *user_data)
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-05-09 14:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-09 9:24 [PATCH] dbus: Don't call l_hashmap_remove within l_hashmap_foreach Andrew Zaborowski
2016-05-09 14:23 ` Denis Kenzior
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.