[asterisk-commits] mjordan: branch mjordan/12-cdr-parking r399700 - /team/mjordan/12-cdr-parking...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 24 15:17:58 CDT 2013


Author: mjordan
Date: Tue Sep 24 15:17:53 2013
New Revision: 399700

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=399700
Log:
Prevent AgentComplete event from crashing when things happen out of order


Modified:
    team/mjordan/12-cdr-parking/apps/app_queue.c

Modified: team/mjordan/12-cdr-parking/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-cdr-parking/apps/app_queue.c?view=diff&rev=399700&r1=399699&r2=399700
==============================================================================
--- team/mjordan/12-cdr-parking/apps/app_queue.c (original)
+++ team/mjordan/12-cdr-parking/apps/app_queue.c Tue Sep 24 15:17:53 2013
@@ -1870,13 +1870,21 @@
 	RAII_VAR(struct ast_str *, event_string, NULL, ast_free);
 
 	caller = ast_multi_channel_blob_get_channel(obj, "caller");
+	if (caller) {
+		caller_event_string = ast_manager_build_channel_state_string(caller);
+		if (!caller_event_string) {
+			ast_log(AST_LOG_NOTICE, "No caller event string, bailing\n");
+			return;
+		}
+	}
+
 	agent = ast_multi_channel_blob_get_channel(obj, "agent");
-
-	caller_event_string = ast_manager_build_channel_state_string(caller);
-	agent_event_string = ast_manager_build_channel_state_string_prefix(agent, "Dest");
-
-	if (!caller_event_string || !agent_event_string) {
-		return;
+	if (agent) {
+		agent_event_string = ast_manager_build_channel_state_string_prefix(agent, "Dest");
+		if (!agent_event_string) {
+			ast_log(AST_LOG_NOTICE, "No agent event string, bailing\n");
+			return;
+		}
 	}
 
 	event_string = ast_manager_str_from_json_object(ast_multi_channel_blob_get_json(obj), NULL);
@@ -1888,8 +1896,8 @@
 		"%s"
 		"%s"
 		"%s",
-		ast_str_buffer(caller_event_string),
-		ast_str_buffer(agent_event_string),
+		caller_event_string ? ast_str_buffer(caller_event_string) : "",
+		agent_event_string ? ast_str_buffer(agent_event_string) : "",
 		ast_str_buffer(event_string));
 }
 
@@ -1925,7 +1933,9 @@
 	}
 
 	ast_multi_channel_blob_add_channel(payload, "caller", caller_snapshot);
-	ast_multi_channel_blob_add_channel(payload, "agent", agent_snapshot);
+	if (agent_snapshot) {
+		ast_multi_channel_blob_add_channel(payload, "agent", agent_snapshot);
+	}
 
 	msg = stasis_message_create(type, payload);
 	if (!msg) {
@@ -3959,7 +3969,6 @@
 		ao2_unlock(qe->parent);
 
 		member_call_pending_clear(tmp->member);
-
 		publish_dial_end_event(qe->chan, tmp, NULL, "BUSY");
 		tmp->stillgoing = 0;
 		++*busies;
@@ -5150,9 +5159,6 @@
 	const char *reason = NULL;	/* silence dumb compilers */
 	RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
 
-	ast_assert(peer != NULL);
-	ast_assert(caller != NULL);
-
 	switch (rsn) {
 	case CALLER:
 		reason = "caller";
@@ -5729,7 +5735,7 @@
 	ast_debug(3, "Detected hangup of queue %s channel %s\n", reason == CALLER ? "caller" : "member",
 			channel_blob->snapshot->name);
 
-	ast_queue_log(queue_data->queue->name, caller_snapshot->uniqueid, queue_data->member->membername,
+	ast_queue_log(queue_data->queue->name, queue_data->caller_uniqueid, queue_data->member->membername,
 			reason == CALLER ? "COMPLETECALLER" : "COMPLETEAGENT", "%ld|%ld|%d",
 		(long) (queue_data->starttime - queue_data->holdstart),
 		(long) (time(NULL) - queue_data->starttime), queue_data->caller_pos);




More information about the asterisk-commits mailing list