[Asterisk-code-review] res sorcery memory cache: Implement expire on reload option. (asterisk[master])

Joshua Colp asteriskteam at digium.com
Thu Jun 4 15:17:12 CDT 2015


Joshua Colp has uploaded a new change for review.

  https://gerrit.asterisk.org/589

Change subject: res_sorcery_memory_cache: Implement expire_on_reload option.
......................................................................

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
---
M res/res_sorcery_memory_cache.c
1 file changed, 9 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/89/589/1

diff --git a/res/res_sorcery_memory_cache.c b/res/res_sorcery_memory_cache.c
index 57feb8f..10ef59a 100644
--- a/res/res_sorcery_memory_cache.c
+++ b/res/res_sorcery_memory_cache.c
@@ -888,6 +888,15 @@
  */
 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);
 }
 
 /*!

-- 
To view, visit https://gerrit.asterisk.org/589
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id46aa1957d660556700e689e195eed57c989b85e
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Joshua Colp <jcolp at digium.com>



More information about the asterisk-code-review mailing list