[asterisk-commits] mmichelson: branch group/CCSS r222649 - /team/group/CCSS/main/ccss.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Oct 7 14:31:05 CDT 2009


Author: mmichelson
Date: Wed Oct  7 14:31:01 2009
New Revision: 222649

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=222649
Log:
Fix potential bug in offering logic.

The way it was written would only work if a caller were
limited to a single agent. While this is always true for
generic agents, it will not be the case with native agents.

The cool part is that this code should actually be more
efficient now.


Modified:
    team/group/CCSS/main/ccss.c

Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=222649&r1=222648&r2=222649
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Wed Oct  7 14:31:01 2009
@@ -1231,24 +1231,42 @@
 	return core_instance->core_id;
 }
 
+static int get_core_id_from_channel(struct ast_channel *chan)
+{
+	struct ast_datastore *datastore;
+	struct dialed_cc_interfaces *cc_dialed_interfaces;
+	int core_id;
+
+	ast_channel_lock(chan);
+	if (!(datastore = ast_channel_datastore_find(chan, &dialed_cc_interfaces_info, NULL))) {
+		/* This should be impossible... */
+		ast_channel_unlock(chan);
+		return -1;
+	}
+
+	cc_dialed_interfaces = datastore->data;
+	core_id = cc_dialed_interfaces->core_id;
+	ast_channel_unlock(chan);
+	return core_id;
+}
+
 int ast_cc_offer(struct ast_channel *caller_chan)
 {
 	char *caller = ast_strdupa(caller_chan->name);
 	char *dash = strrchr(caller, '-');
-	struct cc_core_instance *core_instance;
-	enum match_flags match_flags = MATCH_NO_MONITOR;
-	int res;
+	int core_id;
+	int res = -1;
 
 	if (dash) {
 		*dash = '\0';
 	}
 
-	if (!(core_instance = ao2_t_callback_data(cc_core_instances, 0, match_agent, caller, &match_flags, "Find core instance to offer CC"))) {
-		return -1;
-	}
-
-	res = ast_cc_request_state_change(CC_CALLER_OFFERED, core_instance->core_id, "Offer CC to caller");
-	cc_unref(core_instance, "Done with core instance while offering CC");
+	if ((core_id = get_core_id_from_channel(caller_chan)) < 0) {
+		ast_log(LOG_WARNING, "This should not be possible. No core instance found, so can't offer CC to caller\n");
+		return res;
+	}
+
+	res = ast_cc_request_state_change(CC_CALLER_OFFERED, core_id, "Offer CC to caller");
 	return res;
 }
 




More information about the asterisk-commits mailing list