[asterisk-commits] kmoore: trunk r390317 - in /trunk: apps/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 31 14:00:52 CDT 2013


Author: kmoore
Date: Fri May 31 14:00:51 2013
New Revision: 390317

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390317
Log:
Refactor code and fix a reference leak

Refactor some channel blob publishing code to use
ast_channel_publish_blob now that it is available and fix a JSON
reference leak that was occurring during varset publishing.

Modified:
    trunk/apps/app_userevent.c
    trunk/main/pbx.c
    trunk/main/stasis_channels.c

Modified: trunk/apps/app_userevent.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_userevent.c?view=diff&rev=390317&r1=390316&r2=390317
==============================================================================
--- trunk/apps/app_userevent.c (original)
+++ trunk/apps/app_userevent.c Fri May 31 14:00:51 2013
@@ -76,7 +76,6 @@
 		AST_APP_ARG(extra)[100];
 	);
 	RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
-	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
 
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "UserEvent requires an argument (eventname,optional event body)\n");
@@ -115,14 +114,7 @@
 		}
 	}
 
-	msg = ast_channel_blob_create(
-		chan, ast_channel_user_event_type(), blob);
-	if (!msg) {
-		return -1;
-	}
-
-	stasis_publish(ast_channel_topic(chan), msg);
-
+	ast_channel_publish_blob(chan, ast_channel_user_event_type(), blob);
 	return 0;
 }
 

Modified: trunk/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/pbx.c?view=diff&rev=390317&r1=390316&r2=390317
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Fri May 31 14:00:51 2013
@@ -5776,7 +5776,6 @@
 static void publish_hangup_handler_message(const char *action, struct ast_channel *chan, const char *handler)
 {
 	RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
-	RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
 
 	blob = ast_json_pack("{s: s, s: s}",
 			"type", action,
@@ -5785,12 +5784,7 @@
 		return;
 	}
 
-	message = ast_channel_blob_create(chan, ast_channel_hangup_handler_type(), blob);
-	if (!message) {
-		return;
-	}
-
-	stasis_publish(ast_channel_topic(chan), message);
+	ast_channel_publish_blob(chan, ast_channel_hangup_handler_type(), blob);
 }
 
 int ast_pbx_hangup_handler_run(struct ast_channel *chan)

Modified: trunk/main/stasis_channels.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/stasis_channels.c?view=diff&rev=390317&r1=390316&r2=390317
==============================================================================
--- trunk/main/stasis_channels.c (original)
+++ trunk/main/stasis_channels.c Fri May 31 14:00:51 2013
@@ -519,7 +519,6 @@
 
 void ast_channel_publish_varset(struct ast_channel *chan, const char *name, const char *value)
 {
-	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
 
 	ast_assert(name != NULL);
@@ -533,14 +532,7 @@
 		return;
 	}
 
-	msg = ast_channel_blob_create(chan, ast_channel_varset_type(),
-		ast_json_ref(blob));
-
-	if (!msg) {
-		return;
-	}
-
-	publish_message_for_channel_topics(msg, chan);
+	ast_channel_publish_blob(chan, ast_channel_varset_type(), blob);
 }
 
 void ast_publish_channel_state(struct ast_channel *chan)




More information about the asterisk-commits mailing list