[svn-commits] rmudgett: branch group/ccss_failure_response r297684 - in /team/group/ccss_fa...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Dec 6 16:38:49 CST 2010


Author: rmudgett
Date: Mon Dec  6 16:38:43 2010
New Revision: 297684

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=297684
Log:
Make CC state change request calls fail earlier if the core_id is invalid.

* Replace AST_CC_AGENT_RESPONSE_FAILURE_SHORTTERM with
AST_CC_AGENT_RESPONSE_FAILURE_INVALID.

* Add AST_CC_AGENT_RESPONSE_FAILURE_TOO_MANY if the CC request exceeded
system limits.

Modified:
    team/group/ccss_failure_response/channels/sig_pri.c
    team/group/ccss_failure_response/include/asterisk/ccss.h
    team/group/ccss_failure_response/main/ccss.c

Modified: team/group/ccss_failure_response/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/group/ccss_failure_response/channels/sig_pri.c?view=diff&rev=297684&r1=297683&r2=297684
==============================================================================
--- team/group/ccss_failure_response/channels/sig_pri.c (original)
+++ team/group/ccss_failure_response/channels/sig_pri.c Mon Dec  6 16:38:43 2010
@@ -7443,16 +7443,16 @@
 		cc_pvt->cc_request_response_pending = 0;
 
 		/* Convert core response reason to ISDN response status. */
-		status = 3;/* long_term_denial */
+		status = 2;/* short_term_denial */
 		switch (reason) {
 		case AST_CC_AGENT_RESPONSE_SUCCESS:
 			status = 0;/* success */
 			break;
-		case AST_CC_AGENT_RESPONSE_FAILURE_SHORTTERM:
+		case AST_CC_AGENT_RESPONSE_FAILURE_INVALID:
 			status = 2;/* short_term_denial */
 			break;
-		case AST_CC_AGENT_RESPONSE_FAILURE_LONGTERM:
-			status = 3;/* long_term_denial */
+		case AST_CC_AGENT_RESPONSE_FAILURE_TOO_MANY:
+			status = 5;/* queue_full */
 			break;
 		}
 

Modified: team/group/ccss_failure_response/include/asterisk/ccss.h
URL: http://svnview.digium.com/svn/asterisk/team/group/ccss_failure_response/include/asterisk/ccss.h?view=diff&rev=297684&r1=297683&r2=297684
==============================================================================
--- team/group/ccss_failure_response/include/asterisk/ccss.h (original)
+++ team/group/ccss_failure_response/include/asterisk/ccss.h Mon Dec  6 16:38:43 2010
@@ -859,10 +859,12 @@
 };
 
 enum ast_cc_agent_response_reason {
+	/*! CC request accepted */
 	AST_CC_AGENT_RESPONSE_SUCCESS,
-	AST_CC_AGENT_RESPONSE_FAILURE_SHORTTERM,
-	AST_CC_AGENT_RESPONSE_FAILURE_LONGTERM,
-	/* XXX Can't recall what else */
+	/*! CC request not allowed at this time. Invalid state transition. */
+	AST_CC_AGENT_RESPONSE_FAILURE_INVALID,
+	/*! Too many CC requests in the system. */
+	AST_CC_AGENT_RESPONSE_FAILURE_TOO_MANY,
 };
 
 struct ast_cc_agent_callbacks {

Modified: team/group/ccss_failure_response/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/ccss_failure_response/main/ccss.c?view=diff&rev=297684&r1=297683&r2=297684
==============================================================================
--- team/group/ccss_failure_response/main/ccss.c (original)
+++ team/group/ccss_failure_response/main/ccss.c Mon Dec  6 16:38:43 2010
@@ -2620,6 +2620,7 @@
 }
 
 struct cc_state_change_args {
+	struct cc_core_instance *core_instance;/*!< Holds reference to core instance. */
 	enum cc_state state;
 	int core_id;
 	char debug[1];
@@ -2768,6 +2769,8 @@
 {
 	if (!ast_cc_request_is_within_limits()) {
 		ast_log(LOG_WARNING, "Cannot request CC since there is no more room for requests\n");
+		core_instance->agent->callbacks->respond(core_instance->agent,
+			AST_CC_AGENT_RESPONSE_FAILURE_TOO_MANY);
 		ast_cc_failed(core_instance->core_id, "Too many requests in the system");
 		return -1;
 	}
@@ -2806,7 +2809,8 @@
 	 *    call monitor's unsuspend callback.
 	 */
 	if (previous_state == CC_CALLER_REQUESTED) {
-		core_instance->agent->callbacks->respond(core_instance->agent, AST_CC_AGENT_RESPONSE_SUCCESS);
+		core_instance->agent->callbacks->respond(core_instance->agent,
+			AST_CC_AGENT_RESPONSE_SUCCESS);
 		manager_event(EVENT_FLAG_CC, "CCRequestAcknowledged",
 			"CoreID: %d\r\n"
 			"Caller: %s\r\n",
@@ -2943,20 +2947,18 @@
 	ast_log_dynamic_level(cc_logger_level, "Core %d: State change to %d requested. Reason: %s\n",
 			args->core_id, args->state, args->debug);
 
-	if (!(core_instance = find_cc_core_instance(args->core_id))) {
-		ast_log_dynamic_level(cc_logger_level, "Core %d: Unable to find core instance.\n", args->core_id);
-		ast_free(args);
-		return -1;
-	}
+	core_instance = args->core_instance;
 
 	if (!is_state_change_valid(core_instance->current_state, args->state, core_instance->agent)) {
 		ast_log_dynamic_level(cc_logger_level, "Core %d: Invalid state change requested. Cannot go from %s to %s\n",
 				args->core_id, cc_state_to_string(core_instance->current_state), cc_state_to_string(args->state));
 		if (args->state == CC_CALLER_REQUESTED) {
-			/* For out-of-order requests, we need to let the requester know that
+			/*
+			 * For out-of-order requests, we need to let the requester know that
 			 * we can't handle the request now.
 			 */
-			core_instance->agent->callbacks->respond(core_instance->agent, AST_CC_AGENT_RESPONSE_FAILURE_SHORTTERM);
+			core_instance->agent->callbacks->respond(core_instance->agent,
+				AST_CC_AGENT_RESPONSE_FAILURE_INVALID);
 		}
 		ast_free(args);
 		cc_unref(core_instance, "Unref core instance from when it was found earlier");
@@ -2979,6 +2981,7 @@
 	int debuglen;
 	char dummy[1];
 	va_list aq;
+	struct cc_core_instance *core_instance;
 	struct cc_state_change_args *args;
 	/* This initial call to vsnprintf is simply to find what the
 	 * size of the string needs to be
@@ -2994,12 +2997,22 @@
 		return -1;
 	}
 
+	core_instance = find_cc_core_instance(core_id);
+	if (!core_instance) {
+		ast_log_dynamic_level(cc_logger_level, "Core %d: Unable to find core instance.\n",
+			core_id);
+		ast_free(args);
+		return -1;
+	}
+
+	args->core_instance = core_instance;
 	args->state = state;
 	args->core_id = core_id;
 	vsnprintf(args->debug, debuglen, debug, ap);
 
 	res = ast_taskprocessor_push(cc_core_taskprocessor, cc_do_state_change, args);
 	if (res) {
+		cc_unref(core_instance, "Unref core instance. ast_taskprocessor_push failed");
 		ast_free(args);
 	}
 	return res;




More information about the svn-commits mailing list