]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_sorcery_memory_cache: Implement expire_on_reload option. 32/832/1
authorJoshua Colp <jcolp@digium.com>
Thu, 4 Jun 2015 18:11:44 +0000 (15:11 -0300)
committerMark Michelson <mmichelson@digium.com>
Wed, 8 Jul 2015 19:34:58 +0000 (14:34 -0500)
This change implements the expire_on_reload option for memory caches.
If enabled and a reload is performed all objects within the cache
will be expired and the cache emptied.

ASTERISK-25067
Reported by: Matt Jordan

Change-Id: Id46aa1957d660556700e689e195eed57c989b85e

res/res_sorcery_memory_cache.c

index 57feb8f4f131db77d31f43dad3b3419781711ce1..10ef59a35adf62fa8fc6de1407f53e967bc024a7 100644 (file)
@@ -888,6 +888,15 @@ static void sorcery_memory_cache_load(void *data, const struct ast_sorcery *sorc
  */
 static void sorcery_memory_cache_reload(void *data, const struct ast_sorcery *sorcery, const char *type)
 {
+       struct sorcery_memory_cache *cache = data;
+
+       if (!cache->expire_on_reload) {
+               return;
+       }
+
+       ao2_wrlock(cache->objects);
+       remove_all_from_cache(cache);
+       ao2_unlock(cache->objects);
 }
 
 /*!