[svn-commits] mmichelson: branch mmichelson/queue_bugbug r394601 - /team/mmichelson/queue_b...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Jul 17 14:28:31 CDT 2013


Author: mmichelson
Date: Wed Jul 17 14:28:30 2013
New Revision: 394601

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=394601
Log:
Add appropriate locking.

The items that require lock protection are the channel and
bridge IDs in the queue_stasis_data, so their access is now
protected.


Modified:
    team/mmichelson/queue_bugbug/apps/app_queue.c

Modified: team/mmichelson/queue_bugbug/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/queue_bugbug/apps/app_queue.c?view=diff&rev=394601&r1=394600&r2=394601
==============================================================================
--- team/mmichelson/queue_bugbug/apps/app_queue.c (original)
+++ team/mmichelson/queue_bugbug/apps/app_queue.c Wed Jul 17 14:28:30 2013
@@ -5187,6 +5187,8 @@
 
 static void remove_stasis_subscriptions(struct queue_stasis_data *queue_data)
 {
+	SCOPED_AO2LOCK(lock, queue_data);
+
 	queue_data->dying = 1;
 	queue_data->bridge_sub = stasis_unsubscribe(queue_data->bridge_sub);
 	queue_data->channel_sub = stasis_unsubscribe(queue_data->channel_sub);
@@ -5251,17 +5253,21 @@
 		RAII_VAR(struct ast_channel_snapshot *, caller, NULL, ao2_cleanup);
 		RAII_VAR(struct ast_channel_snapshot *, agent, NULL, ao2_cleanup);
 
+		if (ast_json_integer_get(ast_json_object_get(blind_blob->blob, "result")) == AST_BRIDGE_TRANSFER_FAIL) {
+			return;
+		}
+
+		ao2_lock(queue_data);
 		if (ast_strlen_zero(queue_data->bridge_uniqueid) ||
 				strcmp(queue_data->bridge_uniqueid, blind_blob->bridge->uniqueid)) {
-			return;
-		}
-
-		if (ast_json_integer_get(ast_json_object_get(blind_blob->blob, "result")) == AST_BRIDGE_TRANSFER_FAIL) {
+			ao2_unlock(queue_data);
 			return;
 		}
 
 		caller = ast_channel_snapshot_get_latest(queue_data->caller_uniqueid);
 		agent = ast_channel_snapshot_get_latest(queue_data->agent_uniqueid);
+
+		ao2_unlock(queue_data);
 
 		ast_log(LOG_NOTICE, "Detected blind transfer in queue %s\n", queue_data->queue->name);
 		ast_queue_log(queue_data->queue->name, caller->uniqueid, queue_data->member->membername, "TRANSFER", "%s|%s|%ld|%ld|%d",
@@ -5280,23 +5286,27 @@
 		RAII_VAR(struct ast_channel_snapshot *, caller, NULL, ao2_cleanup);
 		RAII_VAR(struct ast_channel_snapshot *, agent, NULL, ao2_cleanup);
 
+		/* BUGBUG Once atxfer_features is merged, we need to also return when
+		 * atxfer_msg->dest == AST_ATTENDED_TRANSFER_THREEWAY
+		 */
+		if (atxfer_msg->result == AST_BRIDGE_TRANSFER_FAIL) {
+			return;
+		}
+
+		ao2_lock(queue_data);
 		if (ast_strlen_zero(queue_data->bridge_uniqueid) ||
 				(strcmp(queue_data->bridge_uniqueid,
 						atxfer_msg->to_transferee.bridge_snapshot->uniqueid) &&
 				 strcmp(queue_data->bridge_uniqueid,
 					 atxfer_msg->to_transfer_target.bridge_snapshot->uniqueid))) {
-			return;
-		}
-
-		/* BUGBUG Once atxfer_features is merged, we need to also return when
-		 * atxfer_msg->dest == AST_ATTENDED_TRANSFER_THREEWAY
-		 */
-		if (atxfer_msg->result == AST_BRIDGE_TRANSFER_FAIL) {
+			ao2_unlock(queue_data);
 			return;
 		}
 
 		caller = ast_channel_snapshot_get_latest(queue_data->caller_uniqueid);
 		agent = ast_channel_snapshot_get_latest(queue_data->agent_uniqueid);
+
+		ao2_unlock(queue_data);
 
 		ast_log(LOG_NOTICE, "Detected attended transfer in queue %s\n", queue_data->queue->name);
 		/* XXX Need to send queue log something-or-other here. Problem is that it doesn't really make
@@ -5404,16 +5414,20 @@
 	RAII_VAR(struct ast_channel_snapshot *, agent, NULL, ao2_cleanup);
 	enum agent_complete_reason reason;
 
+	ao2_lock(queue_data);
 	if (!strcmp(channel_blob->snapshot->uniqueid, queue_data->caller_uniqueid)) {
 		reason = CALLER;
 	} else if (!strcmp(channel_blob->snapshot->uniqueid, queue_data->agent_uniqueid)) {
 		reason = AGENT;
 	} else {
+		ao2_unlock(queue_data);
 		return;
 	}
 
 	caller = ast_channel_snapshot_get_latest(queue_data->caller_uniqueid);
 	agent = ast_channel_snapshot_get_latest(queue_data->agent_uniqueid);
+
+	ao2_unlock(queue_data);
 
 	ast_queue_log(queue_data->queue->name, caller->uniqueid, queue_data->member->membername,
 			reason == CALLER ? "COMPLETECALLER" : "COMPLETEAGENT", "%ld|%ld|%d",
@@ -5443,11 +5457,13 @@
 	}
 
 	if (ast_local_optimization_begin_type() == stasis_message_type(msg)) {
+		SCOPED_AO2LOCK(lock, queue_data);
 		handle_local_optimization_begin(queue_data, msg);
 		return;
 	}
 
 	if (ast_local_optimization_end_type() == stasis_message_type(msg)) {
+		SCOPED_AO2LOCK(lock, queue_data);
 		handle_local_optimization_end(queue_data, msg);
 		return;
 	}




More information about the svn-commits mailing list