summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-05-29 10:50:45 +0200
committerThomas Haller <thaller@redhat.com>2014-05-30 18:39:08 +0200
commit90ab7e83ffae999eb811013e63cb7ef0afc012e4 (patch)
treecb41b5315f86c918b7d3b7d208def6878f4222ae
parent68bd8711d2182babe64a880a80d2d5af139a84ff (diff)
downloadNetworkManager-90ab7e83ffae999eb811013e63cb7ef0afc012e4.tar.gz
platform: fix check_cache_items() to check items in two steps
check_cache_items() iterated over all items and called refresh_object(). But refresh_object() might remove the current object from the cache, so this would break the iteration. Instead check the items in two steps. First find all the objects we care about and build a list of them. Then check them. Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--src/platform/nm-linux-platform.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 2adaf7e60f..a051d23570 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -1278,12 +1278,20 @@ check_cache_items (NMPlatform *platform, struct nl_cache *cache, int ifindex)
{
auto_nl_cache struct nl_cache *cloned_cache = nl_cache_clone (cache);
struct nl_object *object;
+ GPtrArray *objects_to_refresh = g_ptr_array_new_with_free_func ((GDestroyNotify) nl_object_put);
+ guint i;
for (object = nl_cache_get_first (cloned_cache); object; object = nl_cache_get_next (object)) {
- g_assert (nl_object_get_cache (object) == cloned_cache);
- if (object_has_ifindex (object, ifindex))
- refresh_object (platform, object, TRUE, NM_PLATFORM_REASON_CACHE_CHECK);
+ if (object_has_ifindex (object, ifindex)) {
+ nl_object_get (object);
+ g_ptr_array_add (objects_to_refresh, object);
+ }
}
+
+ for (i = 0; i < objects_to_refresh->len; i++)
+ refresh_object (platform, object, TRUE, NM_PLATFORM_REASON_CACHE_CHECK);
+
+ g_ptr_array_free (objects_to_refresh, TRUE);
}
static void