[asterisk-commits] rmudgett: trunk r422701 - in /trunk: ./ funcs/func_channel.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Sep 5 15:38:32 CDT 2014


Author: rmudgett
Date: Fri Sep  5 15:38:27 2014
New Revision: 422701

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=422701
Log:
func_channel.c: Add missing locking to some CHANNEL() requests.

* The CHANNEL() audionativeformat, videonativeformat, audioreadformat, and
audiowriteformat now need locking since the media format rework when
accessing the channel's format pointers.

* Increased the buffer size for CHANNEL() audionativeformat and
videonativeformat output strings since the allow=all can be a lengthy
list.

* Tweaked the CHANNEL() XML documentation for secure_bridge_signaling,
secure_bridge_media, and state.

* Ensured the output buffer is initialized for secure_bridge_signaling and
secure_bridge_media.

* Made use the locked_copy_string() macro instead of inlining it for trace
and checkhangup.
........

Merged revisions 422700 from http://svn.asterisk.org/svn/asterisk/branches/13

Modified:
    trunk/   (props changed)
    trunk/funcs/func_channel.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-13-merged' - no diff available.

Modified: trunk/funcs/func_channel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_channel.c?view=diff&rev=422701&r1=422700&r2=422701
==============================================================================
--- trunk/funcs/func_channel.c (original)
+++ trunk/funcs/func_channel.c Fri Sep  5 15:38:27 2014
@@ -172,13 +172,13 @@
 						<para>R/W set rxgain level on channel drivers that support it.</para>
 					</enum>
 					<enum name="secure_bridge_signaling">
-						<para>Whether or not channels bridged to this channel require secure signaling</para>
+						<para>Whether or not channels bridged to this channel require secure signaling (1/0)</para>
 					</enum>
 					<enum name="secure_bridge_media">
-						<para>Whether or not channels bridged to this channel require secure media</para>
+						<para>Whether or not channels bridged to this channel require secure media (1/0)</para>
 					</enum>
 					<enum name="state">
-						<para>R/O state for channel</para>
+						<para>R/O state of the channel</para>
 					</enum>
 					<enum name="tonezone">
 						<para>R/W zone for indications played</para>
@@ -432,30 +432,32 @@
 	if (!strcasecmp(data, "audionativeformat")) {
 		tmpcap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
 		if (tmpcap) {
-			struct ast_str *codec_buf = ast_str_alloca(64);
-
+			struct ast_str *codec_buf = ast_str_alloca(128);
+
+			ast_channel_lock(chan);
 			ast_format_cap_append_from_cap(tmpcap, ast_channel_nativeformats(chan), AST_MEDIA_TYPE_AUDIO);
+			ast_channel_unlock(chan);
 			ast_copy_string(buf, ast_format_cap_get_names(tmpcap, &codec_buf), len);
 			ao2_ref(tmpcap, -1);
 		}
 	} else if (!strcasecmp(data, "videonativeformat")) {
 		tmpcap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
 		if (tmpcap) {
-			struct ast_str *codec_buf = ast_str_alloca(64);
-
+			struct ast_str *codec_buf = ast_str_alloca(128);
+
+			ast_channel_lock(chan);
 			ast_format_cap_append_from_cap(tmpcap, ast_channel_nativeformats(chan), AST_MEDIA_TYPE_VIDEO);
+			ast_channel_unlock(chan);
 			ast_copy_string(buf, ast_format_cap_get_names(tmpcap, &codec_buf), len);
 			ao2_ref(tmpcap, -1);
 		}
 	} else if (!strcasecmp(data, "audioreadformat")) {
-		ast_copy_string(buf, ast_format_get_name(ast_channel_readformat(chan)), len);
+		locked_copy_string(chan, buf, ast_format_get_name(ast_channel_readformat(chan)), len);
 	} else if (!strcasecmp(data, "audiowriteformat")) {
-		ast_copy_string(buf, ast_format_get_name(ast_channel_writeformat(chan)), len);
+		locked_copy_string(chan, buf, ast_format_get_name(ast_channel_writeformat(chan)), len);
 #ifdef CHANNEL_TRACE
 	} else if (!strcasecmp(data, "trace")) {
-		ast_channel_lock(chan);
-		ast_copy_string(buf, ast_channel_trace_is_enabled(chan) ? "1" : "0", len);
-		ast_channel_unlock(chan);
+		locked_copy_string(chan, buf, ast_channel_trace_is_enabled(chan) ? "1" : "0", len);
 #endif
 	} else if (!strcasecmp(data, "tonezone") && ast_channel_zone(chan)) {
 		locked_copy_string(chan, buf, ast_channel_zone(chan)->country, len);
@@ -478,9 +480,7 @@
 	else if (!strcasecmp(data, "accountcode"))
 		locked_copy_string(chan, buf, ast_channel_accountcode(chan), len);
 	else if (!strcasecmp(data, "checkhangup")) {
-		ast_channel_lock(chan);
-		ast_copy_string(buf, ast_check_hangup(chan) ? "1" : "0", len);
-		ast_channel_unlock(chan);
+		locked_copy_string(chan, buf, ast_check_hangup(chan) ? "1" : "0", len);
 	} else if (!strcasecmp(data, "peeraccount"))
 		locked_copy_string(chan, buf, ast_channel_peeraccount(chan), len);
 	else if (!strcasecmp(data, "hangupsource"))
@@ -553,9 +553,11 @@
 	} else if (!strncasecmp(data, "secure_bridge_", 14)) {
 		struct ast_datastore *ds;
 
+		buf[0] = '\0';
 		ast_channel_lock(chan);
 		if ((ds = ast_channel_datastore_find(chan, &secure_call_info, NULL))) {
 			struct ast_secure_call_store *encrypt = ds->data;
+
 			if (!strcasecmp(data, "secure_bridge_signaling")) {
 				snprintf(buf, len, "%s", encrypt->signaling ? "1" : "");
 			} else if (!strcasecmp(data, "secure_bridge_media")) {




More information about the asterisk-commits mailing list