[asterisk-commits] mjordan: trunk r389785 - in /trunk: main/ res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat May 25 23:47:22 CDT 2013


Author: mjordan
Date: Sat May 25 23:47:17 2013
New Revision: 389785

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=389785
Log:
Fix a variety of memory corruption/assertion errors

* Initialize a Stasis-Core message type prior to initializing a caching topic.
  The caching topic will attempt to use the message type.
* Don't attempt to publish Stasis-Core messages from remote console connections.
  They aren't the main process; they shouldn't attempt to behave as it (they also
  don't have the infrastructure to do so)
* Don't treat a JSON object as an ao2 object (whoops)
* In asterisk.c, ref bump the JSON even package that is distributed with the
  event meta data. The callers assume that they own the reference, and the packing
  routine steals references.

Modified:
    trunk/main/asterisk.c
    trunk/main/devicestate.c
    trunk/res/res_fax.c

Modified: trunk/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/asterisk.c?view=diff&rev=389785&r1=389784&r2=389785
==============================================================================
--- trunk/main/asterisk.c (original)
+++ trunk/main/asterisk.c Sat May 25 23:47:17 2013
@@ -1140,6 +1140,7 @@
 		return;
 	}
 
+	ast_json_ref(obj);
 	event_info = ast_json_pack("{s: s, s: i, s: o}",
 			"type", message_type,
 			"class_type", EVENT_FLAG_SYSTEM,
@@ -2007,10 +2008,15 @@
 		}
 	}
 	active_channels = ast_active_channels();
-	json_object = ast_json_pack("{s: s, s: s}",
-			"Shutdown", active_channels ? "Uncleanly" : "Cleanly",
-			"Restart", restart ? "True" : "False");
-	publish_system_message("Shutdown", json_object);
+	/* Don't publish messages if we're a remote console - we won't have all of the Stasis
+	 * topics or message types
+	 */
+	if (!ast_opt_remote) {
+		json_object = ast_json_pack("{s: s, s: s}",
+				"Shutdown", active_channels ? "Uncleanly" : "Cleanly",
+				"Restart", restart ? "True" : "False");
+		publish_system_message("Shutdown", json_object);
+	}
 	ast_verb(0, "Asterisk %s ending (%d).\n",
 		active_channels ? "uncleanly" : "cleanly", num);
 

Modified: trunk/main/devicestate.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/devicestate.c?view=diff&rev=389785&r1=389784&r2=389785
==============================================================================
--- trunk/main/devicestate.c (original)
+++ trunk/main/devicestate.c Sat May 25 23:47:17 2013
@@ -784,6 +784,9 @@
 
 int devstate_init(void)
 {
+	if (STASIS_MESSAGE_TYPE_INIT(ast_device_state_message_type) != 0) {
+		return -1;
+	}
 	device_state_topic_all = stasis_topic_create("ast_device_state_topic");
 	if (!device_state_topic_all) {
 		return -1;
@@ -792,9 +795,6 @@
 	if (!device_state_topic_cached) {
 		return -1;
 	}
-	if (STASIS_MESSAGE_TYPE_INIT(ast_device_state_message_type) != 0) {
-		return -1;
-	}
 	device_state_topic_pool = stasis_topic_pool_create(ast_device_state_topic_all());
 	if (!device_state_topic_pool) {
 		return -1;

Modified: trunk/res/res_fax.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_fax.c?view=diff&rev=389785&r1=389784&r2=389785
==============================================================================
--- trunk/res/res_fax.c (original)
+++ trunk/res/res_fax.c Sat May 25 23:47:17 2013
@@ -2246,7 +2246,7 @@
  */
 static int report_send_fax_status(struct ast_channel *chan, struct ast_fax_session_details *details)
 {
-	RAII_VAR(struct ast_json *, json_obj, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_json *, json_obj, NULL, ast_json_unref);
 	RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
 	struct ast_json *json_filenames;
 
@@ -2257,7 +2257,7 @@
 
 	{
 		SCOPED_CHANNELLOCK(lock, chan);
-		json_obj = ast_json_pack("{s: s, s: s, s: s, s: s, s: s, s: s, s: s, s: o}",
+		json_obj = ast_json_pack("{s: s, s: s, s: s, s: s, s: s, s: s, s: o}",
 				"type", "send"
 				"remote_station_id", S_OR(pbx_builtin_getvar_helper(chan, "REMOTESTATIONID"), ""),
 				"local_station_id", S_OR(pbx_builtin_getvar_helper(chan, "LOCALSTATIONID"), ""),




More information about the asterisk-commits mailing list