diff options
author | Richard Mudgett <rmudgett@digium.com> | 2014-04-04 17:57:46 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2014-04-04 17:57:46 +0000 |
commit | 9be438299d47e71a36d252ea55d5432ac751504f (patch) | |
tree | 2a59d59bca780d66e241901f477c630a17ded9b2 /main/stasis_cache.c | |
parent | 73f337d97be6600f283a6149a7dfd107fb3a66e3 (diff) |
Add some asserts that were handy when looking for a stasis cache problem.
* Assert if a channel is destroyed but has the snapshot staging flag set.
In this case the final channel destruction snapshot would never get taken.
* Assert if what we just got out of the stasis cache is not what we were
looking for. This assert would have saved several days searching for a
bug and a lot of my hair.
* Assert if the music on hold message posts could not find the associated
channel. A crash will happen later when manager tries to send the MOH AMI
message. This assert catches the problem when the stasis message is
posted instead of by the thread processing the defective message.
* Always generate a backtrace when an ast_assert() fails.
Review: https://reviewboard.asterisk.org/r/3411/
........
Merged revisions 411701 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@411702 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/stasis_cache.c')
-rw-r--r-- | main/stasis_cache.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/main/stasis_cache.c b/main/stasis_cache.c index 12f49963c..c1dab8539 100644 --- a/main/stasis_cache.c +++ b/main/stasis_cache.c @@ -343,10 +343,17 @@ struct stasis_message *stasis_cache_entry_get_remote(struct stasis_cache_entry * static struct stasis_cache_entry *cache_find(struct ao2_container *entries, struct stasis_message_type *type, const char *id) { struct cache_entry_key search_key; + struct stasis_cache_entry *entry; search_key.type = type; search_key.id = id; - return ao2_find(entries, &search_key, OBJ_SEARCH_KEY | OBJ_NOLOCK); + entry = ao2_find(entries, &search_key, OBJ_SEARCH_KEY | OBJ_NOLOCK); + + /* Ensure that what we looked for is what we found. */ + ast_assert(!entry + || (!strcmp(stasis_message_type_name(entry->key.type), + stasis_message_type_name(type)) && !strcmp(entry->key.id, id))); + return entry; } /*! |