diff options
author | Thomas Graf <tgraf@suug.ch> | 2012-11-15 20:49:33 +0100 |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2012-11-15 20:49:33 +0100 |
commit | 3ed1f9ab5fba2b43fb3c67ac03e0da90ac042ed0 (patch) | |
tree | c2702b392307a2ec3b4486be5b21b0da28ca8e30 | |
parent | c658a6eef8bfaa9347305e532f063cb848087d31 (diff) | |
download | libnl-3ed1f9ab5fba2b43fb3c67ac03e0da90ac042ed0.tar.gz |
cache: Hold cache reference while a cache is being provided
Signed-off-by: Thomas Graf <tgraf@suug.ch>
-rw-r--r-- | lib/cache_mngt.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/cache_mngt.c b/lib/cache_mngt.c index fa1ac22..540c5c1 100644 --- a/lib/cache_mngt.c +++ b/lib/cache_mngt.c @@ -217,8 +217,10 @@ void nl_cache_mngt_provide(struct nl_cache *cache) ops = cache_ops_lookup_for_obj(cache->c_ops->co_obj_ops); if (!ops) BUG(); - else + else { + nl_cache_get(cache); ops->co_major_cache = cache; + } } /** @@ -236,8 +238,10 @@ void nl_cache_mngt_unprovide(struct nl_cache *cache) ops = cache_ops_lookup_for_obj(cache->c_ops->co_obj_ops); if (!ops) BUG(); - else if (ops->co_major_cache == cache) + else if (ops->co_major_cache == cache) { + nl_cache_free(ops->co_major_cache); ops->co_major_cache = NULL; + } } struct nl_cache *__nl_cache_mngt_require(const char *name) |