[asterisk-commits] mjordan: branch mjordan/12-stasis-performance r414972 - in /team/mjordan/12-s...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat May 31 16:59:27 CDT 2014


Author: mjordan
Date: Sat May 31 16:59:21 2014
New Revision: 414972

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=414972
Log:
Remove things seen during self-review

Modified:
    team/mjordan/12-stasis-performance/apps/app_queue.c
    team/mjordan/12-stasis-performance/include/asterisk/stasis_channels.h
    team/mjordan/12-stasis-performance/main/bridge_channel.c
    team/mjordan/12-stasis-performance/main/cdr.c
    team/mjordan/12-stasis-performance/main/channel.c
    team/mjordan/12-stasis-performance/main/pbx.c
    team/mjordan/12-stasis-performance/main/stasis_cache.c
    team/mjordan/12-stasis-performance/main/stasis_channels.c
    team/mjordan/12-stasis-performance/res/res_agi.c
    team/mjordan/12-stasis-performance/res/res_pjsip/pjsip_configuration.c

Modified: team/mjordan/12-stasis-performance/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-stasis-performance/apps/app_queue.c?view=diff&rev=414972&r1=414971&r2=414972
==============================================================================
--- team/mjordan/12-stasis-performance/apps/app_queue.c (original)
+++ team/mjordan/12-stasis-performance/apps/app_queue.c Sat May 31 16:59:21 2014
@@ -3506,9 +3506,7 @@
 				     "Queue", q->name,
 				     "Position", qe->pos,
 				     "Count", q->count);
-		ast_channel_lock(qe->chan);
 		ast_channel_publish_cached_blob(qe->chan, queue_caller_join_type(), blob);
-		ast_channel_unlock(qe->chan);
 		ast_debug(1, "Queue '%s' Join, Channel '%s', Position '%d'\n", q->name, ast_channel_name(qe->chan), qe->pos );
 	}
 	ao2_unlock(q);
@@ -3787,9 +3785,7 @@
 					     "Queue", q->name,
 					     "Position", qe->pos,
 					     "Count", q->count);
-			ast_channel_lock(qe->chan);
 			ast_channel_publish_cached_blob(qe->chan, queue_caller_leave_type(), blob);
-			ast_channel_unlock(qe->chan);
 			ast_debug(1, "Queue '%s' Leave, Channel '%s'\n", q->name, ast_channel_name(qe->chan));
 			/* Take us out of the queue */
 			if (prev) {
@@ -4391,9 +4387,7 @@
 	qe->parent->callsabandoned++;
 	ao2_unlock(qe->parent);
 
-	ast_channel_lock(qe->chan);
 	ast_channel_publish_cached_blob(qe->chan, queue_caller_abandon_type(), blob);
-	ast_channel_unlock(qe->chan);
 }
 
 /*! \brief RNA == Ring No Answer. Common code that is executed when we try a queue member and they don't answer. */

Modified: team/mjordan/12-stasis-performance/include/asterisk/stasis_channels.h
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-stasis-performance/include/asterisk/stasis_channels.h?view=diff&rev=414972&r1=414971&r2=414972
==============================================================================
--- team/mjordan/12-stasis-performance/include/asterisk/stasis_channels.h (original)
+++ team/mjordan/12-stasis-performance/include/asterisk/stasis_channels.h Sat May 31 16:59:21 2014
@@ -308,6 +308,20 @@
 void ast_channel_publish_blob(struct ast_channel *chan, struct stasis_message_type *type,
 	struct ast_json *blob);
 
+/*!
+ * \brief Publish a channel blob message using the latest snapshot from the cache
+ * \since 12.4.0
+ *
+ * \param chan Channel publishing the blob.
+ * \param type Type of stasis message.
+ * \param blob The blob being published. (NULL if no blob)
+ *
+ * \note As this only accesses the uniqueid and topic of the channel - neither of
+ * which should ever be changed on a channel anyhow - a channel does not have to
+ * be locked when calling this function.
+ *
+ * \return Nothing
+ */
 void ast_channel_publish_cached_blob(struct ast_channel *chan, struct stasis_message_type *type,
 	struct ast_json *blob);
 

Modified: team/mjordan/12-stasis-performance/main/bridge_channel.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-stasis-performance/main/bridge_channel.c?view=diff&rev=414972&r1=414971&r2=414972
==============================================================================
--- team/mjordan/12-stasis-performance/main/bridge_channel.c (original)
+++ team/mjordan/12-stasis-performance/main/bridge_channel.c Sat May 31 16:59:21 2014
@@ -838,18 +838,16 @@
 		datalen = 0;
 	}
 
-	ast_channel_lock(bridge_channel->chan);
 	ast_channel_publish_cached_blob(bridge_channel->chan, ast_channel_hold_type(), blob);
-	ast_channel_unlock(bridge_channel->chan);
+
 	return ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_HOLD,
 		moh_class, datalen);
 }
 
 int ast_bridge_channel_write_unhold(struct ast_bridge_channel *bridge_channel)
 {
-	ast_channel_lock(bridge_channel->chan);
 	ast_channel_publish_cached_blob(bridge_channel->chan, ast_channel_unhold_type(), NULL);
-	ast_channel_unlock(bridge_channel->chan);
+
 	return ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_UNHOLD, NULL, 0);
 }
 

Modified: team/mjordan/12-stasis-performance/main/cdr.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-stasis-performance/main/cdr.c?view=diff&rev=414972&r1=414971&r2=414972
==============================================================================
--- team/mjordan/12-stasis-performance/main/cdr.c (original)
+++ team/mjordan/12-stasis-performance/main/cdr.c Sat May 31 16:59:21 2014
@@ -2120,6 +2120,7 @@
 		ao2_callback(active_cdrs_by_channel, OBJ_NODATA, cdr_object_finalize_party_b,
 			old_snapshot);
 	}
+
 }
 
 struct bridge_leave_data {

Modified: team/mjordan/12-stasis-performance/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-stasis-performance/main/channel.c?view=diff&rev=414972&r1=414971&r2=414972
==============================================================================
--- team/mjordan/12-stasis-performance/main/channel.c (original)
+++ team/mjordan/12-stasis-performance/main/channel.c Sat May 31 16:59:21 2014
@@ -1270,7 +1270,6 @@
 	struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HOLD };
 	int res;
 
-	ast_channel_lock(chan);
 	if (!ast_strlen_zero(musicclass)) {
 		f.data.ptr = (void *) musicclass;
 		f.datalen = strlen(musicclass) + 1;
@@ -1282,7 +1281,7 @@
 	ast_channel_publish_cached_blob(chan, ast_channel_hold_type(), blob);
 
 	res = ast_queue_frame(chan, &f);
-	ast_channel_unlock(chan);
+
 	return res;
 }
 
@@ -1291,11 +1290,10 @@
 	struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_UNHOLD };
 	int res;
 
-	ast_channel_lock(chan);
 	ast_channel_publish_cached_blob(chan, ast_channel_unhold_type(), NULL);
 
 	res = ast_queue_frame(chan, &f);
-	ast_channel_unlock(chan);
+
 	return res;
 }
 

Modified: team/mjordan/12-stasis-performance/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-stasis-performance/main/pbx.c?view=diff&rev=414972&r1=414971&r2=414972
==============================================================================
--- team/mjordan/12-stasis-performance/main/pbx.c (original)
+++ team/mjordan/12-stasis-performance/main/pbx.c Sat May 31 16:59:21 2014
@@ -8347,7 +8347,7 @@
 	chan = ast_channel_get_by_name(a->argv[e->args]);
 	if (!chan) {
 		ast_cli(a->fd, "Channel '%s' not found\n", a->argv[e->args]);
-		return CLI_FAILURE;		
+		return CLI_FAILURE;
 	}
 
 	ast_channel_lock(chan);

Modified: team/mjordan/12-stasis-performance/main/stasis_cache.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-stasis-performance/main/stasis_cache.c?view=diff&rev=414972&r1=414971&r2=414972
==============================================================================
--- team/mjordan/12-stasis-performance/main/stasis_cache.c (original)
+++ team/mjordan/12-stasis-performance/main/stasis_cache.c Sat May 31 16:59:21 2014
@@ -127,9 +127,16 @@
 	return NULL;
 }
 
+/*!
+ * \brief The key for an entry in the cache
+ * \note The items in this struct must be immutable for the item in the cache
+ */
 struct cache_entry_key {
+	/*! The message type of the item stored in the cache */
 	struct stasis_message_type *type;
-	const char *id;	
+	/*! The unique ID of the item stored in the cache */
+	const char *id;
+	/*! The hash, computed from \c type and \c id */
 	unsigned int hash;
 };
 

Modified: team/mjordan/12-stasis-performance/main/stasis_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-stasis-performance/main/stasis_channels.c?view=diff&rev=414972&r1=414971&r2=414972
==============================================================================
--- team/mjordan/12-stasis-performance/main/stasis_channels.c (original)
+++ team/mjordan/12-stasis-performance/main/stasis_channels.c Sat May 31 16:59:21 2014
@@ -197,23 +197,15 @@
 	ao2_cleanup(snapshot->manager_vars);
 }
 
-static int64_t GLOBAL_CUMULATIVE_TIME;
-static int64_t GLOBAL_SNAPSHOTS;
-
 struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *chan)
 {
 	struct ast_channel_snapshot *snapshot;
 	struct ast_bridge *bridge;
-	int64_t snap_time;
-	struct timeval start;
-	struct timeval end;
 
 	/* no snapshots for dummy channels */
 	if (!ast_channel_tech(chan)) {
 		return NULL;
 	}
-
-	start = ast_tvnow();
 
 	snapshot = ao2_alloc(sizeof(*snapshot), channel_snapshot_dtor);
 	if (!snapshot || ast_string_field_init(snapshot, 1024)) {
@@ -277,12 +269,6 @@
 	snapshot->manager_vars = ast_channel_get_manager_vars(chan);
 	snapshot->tech_properties = ast_channel_tech(chan)->properties;
 
-	end = ast_tvnow();
-
-	snap_time = ast_tvdiff_us(end, start);
-	GLOBAL_CUMULATIVE_TIME += snap_time;
-	GLOBAL_SNAPSHOTS += 1;
-
 	return snapshot;
 }
 
@@ -677,11 +663,11 @@
 }
 
 void ast_channel_publish_cached_blob(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
-{
+{	
 	struct stasis_message *message;
 
-	if (!blob) { 
-		blob = ast_json_null();
+	if (!blob) {
+		blob = ast_json_unref_null();
 	}
 
 	message = ast_channel_blob_create_from_cache(ast_channel_uniqueid(chan), type, blob);

Modified: team/mjordan/12-stasis-performance/res/res_agi.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-stasis-performance/res/res_agi.c?view=diff&rev=414972&r1=414971&r2=414972
==============================================================================
--- team/mjordan/12-stasis-performance/res/res_agi.c (original)
+++ team/mjordan/12-stasis-performance/res/res_agi.c Sat May 31 16:59:21 2014
@@ -1481,9 +1481,10 @@
 	   to execute based on the setup info */
 	ast_uri_encode(agi_buffer, ami_buffer, AMI_BUF_SIZE, ast_uri_http);
 	startblob = ast_json_pack("{s: s}", "Env", ami_buffer);
+
+	ast_channel_publish_cached_blob(chan, agi_async_start_type(), startblob);
+
 	ast_channel_lock(chan);
-	ast_channel_publish_cached_blob(chan, agi_async_start_type(), startblob);
-
 	hungup = ast_check_hangup(chan);
 	ast_channel_unlock(chan);
 	for (;;) {
@@ -1529,9 +1530,7 @@
 			if (execblob && !ast_strlen_zero(cmd->cmd_id)) {
 				ast_json_object_set(execblob, "CommandId", ast_json_string_create(cmd->cmd_id));
 			}
-			ast_channel_lock(chan);
 			ast_channel_publish_cached_blob(chan, agi_async_exec_type(), execblob);
-			ast_channel_unlock(chan);
 
 			free_agi_cmd(cmd);
 
@@ -1591,9 +1590,7 @@
 		ast_speech_destroy(async_agi.speech);
 	}
 	/* notify manager users this channel cannot be controlled anymore by Async AGI */
-	ast_channel_lock(chan);
 	ast_channel_publish_cached_blob(chan, agi_async_end_type(), NULL);
-	ast_channel_unlock(chan);
 
 async_agi_abort:
 	/* close the pipe */
@@ -3665,9 +3662,7 @@
 			     "Command", command,
 			     "ResultCode", result_code,
 			     "Result", result);
-	ast_channel_lock(chan);
 	ast_channel_publish_cached_blob(chan, agi_exec_end_type(), blob);
-	ast_channel_unlock(chan);
 }
 
 static enum agi_result agi_handle_command(struct ast_channel *chan, AGI *agi, char *buf, int dead)
@@ -3685,9 +3680,7 @@
 	startblob = ast_json_pack("{s: i, s: s}",
 			     "CommandId", command_id,
 			     "Command", ami_cmd);
-	ast_channel_lock(chan);
 	ast_channel_publish_cached_blob(chan, agi_exec_start_type(), startblob);
-	ast_channel_unlock(chan);
 
 	parse_args(buf, &argc, argv);
 	c = find_command(argv, 0);

Modified: team/mjordan/12-stasis-performance/res/res_pjsip/pjsip_configuration.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-stasis-performance/res/res_pjsip/pjsip_configuration.c?view=diff&rev=414972&r1=414971&r2=414972
==============================================================================
--- team/mjordan/12-stasis-performance/res/res_pjsip/pjsip_configuration.c (original)
+++ team/mjordan/12-stasis-performance/res/res_pjsip/pjsip_configuration.c Sat May 31 16:59:21 2014
@@ -1444,7 +1444,7 @@
 
 		ast_str_append(&context->output_buffer, 0,
 			"%*s: %-*.*s  CLCID: \"%s\" <%s>\n",
-			indent, "Exten", 
+			indent, "Exten",
 			flexwidth, flexwidth,
 			snapshot->exten,
 			snapshot->connected_name,




More information about the asterisk-commits mailing list