[asterisk-commits] mjordan: trunk r393785 - /trunk/main/channel.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jul 7 16:29:42 CDT 2013


Author: mjordan
Date: Sun Jul  7 16:29:40 2013
New Revision: 393785

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=393785
Log:
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


Modified:
    trunk/main/channel.c

Modified: trunk/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/channel.c?view=diff&rev=393785&r1=393784&r2=393785
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Sun Jul  7 16:29:40 2013
@@ -2360,11 +2360,22 @@
 	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);
 
@@ -2403,14 +2414,6 @@
 	} else {
 		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))




More information about the asterisk-commits mailing list