summaryrefslogtreecommitdiff
path: root/main/stasis_cache.c
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2014-08-06 12:55:28 +0000
committerKinsey Moore <kmoore@digium.com>2014-08-06 12:55:28 +0000
commitf1036f40dc22c4d4b30cc2ab36199cd749ead9c5 (patch)
tree4fd17b406cb14b5eee97cf0be44382b792ccbff9 /main/stasis_cache.c
parentac5c75b45d9d7fe047ccd9d1d094cb9d30df8b51 (diff)
Stasis: Allow message types to be blocked
This introduces stasis.conf and a mechanism to prevent certain message types from being published. Internally, this works by preventing the chosen message types from being created which ensures that those message types can never be published. This patch also adjusts message publishers such that message payloads are not created if the related message type is not available. ASTERISK-23943 #close Review: https://reviewboard.asterisk.org/r/3823/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@420124 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/stasis_cache.c')
-rw-r--r--main/stasis_cache.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/main/stasis_cache.c b/main/stasis_cache.c
index 8b4304e5f..c492307d6 100644
--- a/main/stasis_cache.c
+++ b/main/stasis_cache.c
@@ -185,10 +185,13 @@ static struct stasis_cache_entry *cache_entry_create(struct stasis_message_type
struct stasis_cache_entry *entry;
int is_remote;
- ast_assert(type != NULL);
ast_assert(id != NULL);
ast_assert(snapshot != NULL);
+ if (!type) {
+ return NULL;
+ }
+
entry = ao2_alloc_options(sizeof(*entry), cache_entry_dtor,
AO2_ALLOC_OPT_LOCK_NOLOCK);
if (!entry) {
@@ -550,9 +553,12 @@ struct ao2_container *stasis_cache_get_all(struct stasis_cache *cache, struct st
ast_assert(cache != NULL);
ast_assert(cache->entries != NULL);
- ast_assert(type != NULL);
ast_assert(id != NULL);
+ if (!type) {
+ return NULL;
+ }
+
found = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_NOLOCK, 0, NULL, NULL);
if (!found) {
return NULL;
@@ -619,9 +625,12 @@ struct stasis_message *stasis_cache_get_by_eid(struct stasis_cache *cache, struc
ast_assert(cache != NULL);
ast_assert(cache->entries != NULL);
- ast_assert(type != NULL);
ast_assert(id != NULL);
+ if (!type) {
+ return NULL;
+ }
+
ao2_rdlock(cache->entries);
cached_entry = cache_find(cache->entries, type, id);
@@ -752,6 +761,10 @@ static struct stasis_message *update_create(struct stasis_message *old_snapshot,
ast_assert(old_snapshot != NULL || new_snapshot != NULL);
+ if (!stasis_cache_update_type()) {
+ return NULL;
+ }
+
update = ao2_alloc_options(sizeof(*update), stasis_cache_update_dtor,
AO2_ALLOC_OPT_LOCK_NOLOCK);
if (!update) {