[svn-commits] mmichelson: branch mmichelson/queue_bugbug r394463 - /team/mmichelson/queue_b...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Tue Jul 16 12:52:15 CDT 2013
Author: mmichelson
Date: Tue Jul 16 12:52:13 2013
New Revision: 394463
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=394463
Log:
Prevent crashes when performing blind transfer.
Be sure to kill all stasis subscriptions when we no longer
expect to get any more traffic. Some further safeguards may
be necessary since stasis messages that we receive on separate
topics may come from separate threads.
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=394463&r1=394462&r2=394463
==============================================================================
--- team/mmichelson/queue_bugbug/apps/app_queue.c (original)
+++ team/mmichelson/queue_bugbug/apps/app_queue.c Tue Jul 16 12:52:13 2013
@@ -5162,6 +5162,10 @@
int caller_pos;
int callcompletedinsl;
int hangup_detected;
+ struct stasis_subscription *bridge_sub;
+ struct stasis_subscription *caller_sub;
+ struct stasis_subscription *local_caller_sub;
+ struct stasis_subscription *agent_sub;
};
static void queue_stasis_data_destructor(void *obj)
@@ -5170,6 +5174,14 @@
ao2_cleanup(queue_data->member);
ast_string_field_free_memory(queue_data);
+}
+
+static void remove_stasis_subscriptions(struct queue_stasis_data *queue_data)
+{
+ queue_data->bridge_sub = stasis_unsubscribe(queue_data->bridge_sub);
+ queue_data->caller_sub = stasis_unsubscribe(queue_data->caller_sub);
+ queue_data->local_caller_sub = stasis_unsubscribe(queue_data->local_caller_sub);
+ queue_data->agent_sub = stasis_unsubscribe(queue_data->agent_sub);
}
static struct queue_stasis_data *queue_stasis_data_alloc(struct queue_ent *qe,
@@ -5224,6 +5236,10 @@
return;
}
+ if (ast_json_integer_get(ast_json_object_get(blind_blob->blob, "result")) == AST_BRIDGE_TRANSFER_FAIL) {
+ return;
+ }
+
caller = ast_channel_snapshot_get_latest(queue_data->caller_uniqueid);
agent = ast_channel_snapshot_get_latest(queue_data->agent_uniqueid);
@@ -5236,7 +5252,7 @@
send_agent_complete(queue_data->queue, caller, agent, queue_data->member,
queue_data->holdstart, queue_data->starttime, TRANSFER);
- stasis_unsubscribe(sub);
+ remove_stasis_subscriptions(queue_data);
} else if (ast_attended_transfer_type() == stasis_message_type(msg)) {
struct ast_attended_transfer_message *atxfer_msg = stasis_message_data(msg);
@@ -5249,7 +5265,7 @@
}
ast_log(LOG_NOTICE, "Detected attended transfer in queue %s\n", queue_data->queue);
- stasis_unsubscribe(sub);
+ remove_stasis_subscriptions(queue_data);
}
}
@@ -5295,7 +5311,7 @@
ast_log(LOG_NOTICE, "Detected hangup request on channel %s\n", channel_blob->snapshot->name);
send_agent_complete(queue_data->queue, caller, agent, queue_data->member,
queue_data->holdstart, queue_data->starttime, reason);
- stasis_unsubscribe(sub);
+ remove_stasis_subscriptions(queue_data);
}
}
@@ -5308,17 +5324,17 @@
if (!queue_data) {
return -1;
}
- stasis_subscribe(ast_bridge_topic_all(), queue_bridge_cb, queue_data);
+ queue_data->bridge_sub = stasis_subscribe(ast_bridge_topic_all(), queue_bridge_cb, queue_data);
ao2_ref(queue_data, +1);
- stasis_subscribe(ast_channel_topic(qe->chan), queue_channel_cb, queue_data);
+ queue_data->caller_sub = stasis_subscribe(ast_channel_topic(qe->chan), queue_channel_cb, queue_data);
ao2_ref(queue_data, +1);
- stasis_subscribe(ast_channel_topic(peer), queue_channel_cb, queue_data);
+ queue_data->agent_sub = stasis_subscribe(ast_channel_topic(peer), queue_channel_cb, queue_data);
if (local_caller) {
/* Local optimization events are published on the ;1 channel topic, so if applicable,
* we need to subscribe to that channel's topic
*/
ao2_ref(queue_data, +1);
- stasis_subscribe(ast_channel_topic(local_caller), queue_channel_cb, queue_data);
+ queue_data->local_caller_sub = stasis_subscribe(ast_channel_topic(local_caller), queue_channel_cb, queue_data);
}
return 0;
}
More information about the svn-commits
mailing list