summaryrefslogtreecommitdiff
path: root/main/channel.c
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2013-07-07 21:29:40 +0000
committerMatthew Jordan <mjordan@digium.com>2013-07-07 21:29:40 +0000
commit70a46e2ee5dd5af7a36bad2223fd81acd6be8906 (patch)
tree123eeef1dbeca59619c7fe5cb727187596156a01 /main/channel.c
parentb193c2873d27e15dfec521c7fef10411e8d1f5c8 (diff)
In a channel destructor dispose of items that raise Stasis message properly
This patch reorders certain actions that may raise Stasis messages in the channel destructor such that they occur before the Stasis cache is cleared. Once the Stasis cache is cleared, its rather a bad idea to be trying to publish information about a channel. (closes issue ASTERISK-22001) Reported by: Jonathan Rose git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393785 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/channel.c')
-rw-r--r--main/channel.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/main/channel.c b/main/channel.c
index 104558b16..8ff9bf213 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -2360,12 +2360,23 @@ static void ast_channel_destructor(void *obj)
char device_name[AST_CHANNEL_NAME];
struct ast_callid *callid;
+ /* Stop monitoring */
+ if (ast_channel_monitor(chan)) {
+ ast_channel_monitor(chan)->stop(chan, 0);
+ }
+
+ /* If there is native format music-on-hold state, free it */
+ if (ast_channel_music_state(chan)) {
+ ast_moh_cleanup(chan);
+ }
+
+ ast_pbx_hangup_handler_destroy(chan);
+
+ /* Things that may possibly raise Stasis messages shouldn't occur after this point */
ast_set_flag(ast_channel_flags(chan), AST_FLAG_DEAD);
ast_channel_publish_snapshot(chan);
publish_cache_clear(chan);
- ast_pbx_hangup_handler_destroy(chan);
-
ast_channel_lock(chan);
/* Get rid of each of the data stores on the channel */
@@ -2404,14 +2415,6 @@ static void ast_channel_destructor(void *obj)
device_name[0] = '\0';
}
- /* Stop monitoring */
- if (ast_channel_monitor(chan))
- ast_channel_monitor(chan)->stop( chan, 0 );
-
- /* If there is native format music-on-hold state, free it */
- if (ast_channel_music_state(chan))
- ast_moh_cleanup(chan);
-
/* Free translators */
if (ast_channel_readtrans(chan))
ast_translator_free_path(ast_channel_readtrans(chan));