[asterisk-commits] mmichelson: branch group/CCSS r217457 - in /team/group/CCSS: apps/ main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Sep 9 14:21:13 CDT 2009
Author: mmichelson
Date: Wed Sep 9 14:21:11 2009
New Revision: 217457
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=217457
Log:
More logic regarding killing of duplicate offers. It's a bit
ugly, but it should work. I can work on making it neater later.
Modified:
team/group/CCSS/apps/app_dial.c
team/group/CCSS/main/ccss.c
Modified: team/group/CCSS/apps/app_dial.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/apps/app_dial.c?view=diff&rev=217457&r1=217456&r2=217457
==============================================================================
--- team/group/CCSS/apps/app_dial.c (original)
+++ team/group/CCSS/apps/app_dial.c Wed Sep 9 14:21:11 2009
@@ -1975,8 +1975,13 @@
if (!cc_interfaces->core_created) {
core_id = ast_cc_core_init_instance(inbound, cc_interfaces->interface_tree);
cc_interfaces->core_created = 1;
- snprintf(core_id_str, sizeof(core_id_str), "%d", core_id);
- pbx_builtin_setvar_helper(inbound, "CC_AVAIL", core_id_str);
+ /* We set the core_created flag to 1 even if the core instance creation was
+ * unsuccessful. This way we don't keep attempting to do it and keep failing.
+ */
+ if (core_id == -1) {
+ snprintf(core_id_str, sizeof(core_id_str), "%d", core_id);
+ pbx_builtin_setvar_helper(inbound, "CC_AVAIL", core_id_str);
+ }
}
}
Modified: team/group/CCSS/main/ccss.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=217457&r1=217456&r2=217457
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Wed Sep 9 14:21:11 2009
@@ -541,10 +541,29 @@
ast_assert(callbacks->destructor != NULL);
}
-static const struct ast_cc_agent_callbacks *find_agent_callbacks(const char * const type)
+static const struct ast_cc_agent_callbacks *find_agent_callbacks(struct ast_channel *chan)
{
struct cc_agent_backend *backend;
const struct ast_cc_agent_callbacks *callbacks = NULL;
+ enum ast_cc_agent_policies agent_policy;
+ const char *type;
+
+ agent_policy = ast_get_cc_agent_policy(ast_channel_get_cc_config_params(chan));
+
+ if (agent_policy == AST_CC_AGENT_GENERIC) {
+ type = "generic";
+ } else if (agent_policy == AST_CC_AGENT_NATIVE) {
+ char chan_name[AST_CHANNEL_NAME];
+ char *slash;
+ ast_copy_string(chan_name, chan->name, sizeof(chan_name));
+ if ((slash = strchr(chan_name, '/'))) {
+ *slash = '\0';
+ }
+ type = chan_name;
+ } else {
+ ast_log(LOG_NOTICE, "Not returning agent callbacks since this channel is configured not to have a CC agent\n");
+ return NULL;
+ }
AST_RWLIST_RDLOCK(&cc_agent_backends);
AST_RWLIST_TRAVERSE(&cc_agent_backends, backend, next) {
@@ -569,11 +588,7 @@
}
agent->core_id = core_id;
- /* XXX Obviously this will need to be revisited.
- * For now, I'm keeping it simple by using only generic
- * agents.
- */
- if (!(agent->callbacks = find_agent_callbacks("generic"))) {
+ if (!(agent->callbacks = find_agent_callbacks(caller_chan))) {
ast_free(agent);
return NULL;
}
@@ -630,13 +645,14 @@
*/
kill_duplicate_offers(caller);
- /* XXX At this point, I should do an ao2_callback_data to match_agent if the agent being
- * used will be generic. This way, I can detect early if the caller already has an outstanding
- * request and stop at this point.
- *
- * Actually, modifying kill_duplicate_offers would probably be better so that there is only
- * one traversal of the container instead of two.
- */
+ if (ast_get_cc_agent_policy(ast_channel_get_cc_config_params(caller_chan)) == AST_CC_AGENT_GENERIC) {
+ unsigned long match_flags = MATCH_MONITOR;
+ if (ao2_callback_data(cc_core_instances, OBJ_NODATA, match_agent, caller, &match_flags) != NULL) {
+ ast_log(LOG_NOTICE, "Caller %s already has an outstanding CC request. "
+ "Not creating a new core instance\n", caller);
+ return -1;
+ }
+ }
/* Next, we need to create the core instance for this call */
if (!(core_instance = ao2_alloc(sizeof(*core_instance), cc_core_instance_destructor))) {
More information about the asterisk-commits
mailing list