summaryrefslogtreecommitdiff
path: root/res/res_sorcery_memory_cache.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2015-06-04 15:11:44 -0300
committerJoshua Colp <jcolp@digium.com>2015-06-04 15:28:31 -0300
commit128fe4cee8d1bc38471872b1e51ee2eb4cb9b7ae (patch)
tree1bcc76bd79519488b2fade106a664c6650829ea5 /res/res_sorcery_memory_cache.c
parent86c79314f1aff708c71594ab26519cfcb8ec5263 (diff)
res_sorcery_memory_cache: Implement expire_on_reload option.
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
Diffstat (limited to 'res/res_sorcery_memory_cache.c')
-rw-r--r--res/res_sorcery_memory_cache.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/res/res_sorcery_memory_cache.c b/res/res_sorcery_memory_cache.c
index 57feb8f4f..10ef59a35 100644
--- a/res/res_sorcery_memory_cache.c
+++ b/res/res_sorcery_memory_cache.c
@@ -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);
}
/*!