[svn-commits] mmichelson: branch group/CCSS r227376 - /team/group/CCSS/main/ccss.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Nov 3 14:14:48 CST 2009


Author: mmichelson
Date: Tue Nov  3 14:14:45 2009
New Revision: 227376

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=227376
Log:
Adjust the count_agents function a bit.

When making a recall, it doesn't make sense to count the agent allocated
for the call for which the caller is recalling towards the total. That one
is going to go away at the end of the call anyway.


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=227376&r1=227375&r2=227376
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Tue Nov  3 14:14:45 2009
@@ -269,6 +269,11 @@
 	return 0;
 }
 
+struct count_agents_cb_data {
+	int count;
+	int core_id_exception;
+};
+
 /*!
  * \brief Count the number of agents a specific interface is using
  *
@@ -280,10 +285,15 @@
 {
 	struct cc_core_instance *core_instance = obj;
 	const char *name = arg;
-	long *count = data;
+	struct count_agents_cb_data *cb_data = data;
+
+	if (cb_data->core_id_exception == core_instance->core_id) {
+		ast_log_dynamic_level(cc_logger_level, "Found agent with core_id %d but not counting it toward total\n", core_instance->core_id);
+		return 0;
+	}
 
 	if (core_instance->monitor && !strcmp(core_instance->agent->interface, name)) {
-		(*count)++;
+		cb_data->count++;
 	}
 	return 0;
 }
@@ -1734,13 +1744,13 @@
 
 }
 
-static long count_agents(const char * const caller)
-{
-	long agent_count = 0;
-
-	ao2_t_callback_data(cc_core_instances, OBJ_NODATA, count_agents_cb, (char *)caller, &agent_count, "Counting agents");
-	ast_log_dynamic_level(cc_logger_level, "Counted %ld agents\n", agent_count);
-	return agent_count;
+static long count_agents(const char * const caller, const int core_id_exception)
+{
+	struct count_agents_cb_data data = {.core_id_exception = core_id_exception,};
+
+	ao2_t_callback_data(cc_core_instances, OBJ_NODATA, count_agents_cb, (char *)caller, &data, "Counting agents");
+	ast_log_dynamic_level(cc_logger_level, "Counted %d agents\n", data.count);
+	return data.count;
 }
 
 static void kill_duplicate_offers(char *caller) {
@@ -2046,6 +2056,7 @@
 	char caller[AST_CHANNEL_NAME];
 	struct cc_core_instance *core_instance;
 	long agent_count;
+	int recall_core_id;
 
 	ast_channel_get_device_name(caller_chan, caller, sizeof(caller));
 	/* First, we need to kill off other pending CC offers from caller. If the caller is going
@@ -2053,7 +2064,9 @@
 	 */
 	kill_duplicate_offers(caller);
 
-	agent_count = count_agents(caller);
+	ast_cc_is_recall(caller_chan, &recall_core_id);
+
+	agent_count = count_agents(caller, recall_core_id);
 	if (agent_count >= ast_get_cc_max_agents(ast_channel_get_cc_config_params(caller_chan))) {
 		ast_log_dynamic_level(cc_logger_level, "Caller %s already has the maximum number of agents configured\n", caller);
 		return NULL;
@@ -2672,6 +2685,7 @@
 		 * the interface tree for the channel because it shouldn't be
 		 * there. However, this is a recall though, so return true.
 		 */
+		*core_id = recall_data->core_id;
 		ast_channel_unlock(chan);
 		return 1;
 	}




More information about the svn-commits mailing list