[svn-commits] mmichelson: branch group/CCSS r222535 - in /team/group/CCSS: include/asterisk...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Oct 7 11:09:52 CDT 2009


Author: mmichelson
Date: Wed Oct  7 11:09:47 2009
New Revision: 222535

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=222535
Log:
Limit the number of requests in the system.

There is a recommendation documented that receivers of requests
should check before changing state to CC_CALLER_REQUESTED, but there
is a failsafe in the core just in case this recommendation is ignored.


Modified:
    team/group/CCSS/include/asterisk/ccss.h
    team/group/CCSS/main/ccss.c

Modified: team/group/CCSS/include/asterisk/ccss.h
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/include/asterisk/ccss.h?view=diff&rev=222535&r1=222534&r2=222535
==============================================================================
--- team/group/CCSS/include/asterisk/ccss.h (original)
+++ team/group/CCSS/include/asterisk/ccss.h Wed Oct  7 11:09:47 2009
@@ -1049,6 +1049,26 @@
 
 /*!
  * \since 1.6.4
+ * \brief Check if the incoming CC request is within the bounds
+ * set by the cc_max_requests configuration option
+ *
+ * It is recommended that an entity which receives an incoming
+ * CC request calls this function before changing state to 
+ * CC_CALLER_REQUESTED. This way, immediate feedback can be
+ * given to the caller about why his request was rejected.
+ *
+ * If this is not called and a state change to CC_CALLER_REQUESTED
+ * is made, then the core will still not allow for the request
+ * to succeed. However, if done this way, it may not be obvious
+ * to the requestor why the request failed.
+ *
+ * \retval 0 Not within the limits. Fail.
+ * \retval non-zero Within the limits. Success.
+ */
+int ast_cc_request_within_limits(void);
+
+/*!
+ * \since 1.6.4
  * \brief Initialize CCSS
  *
  * XXX This needs to be updated as more functionality is added.

Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=222535&r1=222534&r2=222535
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Wed Oct  7 11:09:47 2009
@@ -1765,6 +1765,10 @@
 				(core_instance->current_state == CC_AVAILABLE && ast_test_flag(core_instance->agent, AST_CC_AGENT_SKIP_OFFER)))) {
 			ast_log(LOG_NOTICE, "Invalid state change request. Cannot go from %d to %d\n", core_instance->current_state, args->state);
 		}
+		if (!ast_cc_request_within_limits()) {
+			ast_log(LOG_WARNING, "Cannot request CC since there is no more room for requests\n");
+			ast_cc_request_state_change(CC_FAILED, core_instance->core_id, "Too many requests in the system");
+		}
 		core_instance->current_state = args->state;
 		core_instance->agent->callbacks->stop_offer_timer(core_instance->agent);
 		cc_monitor_tree_init(args->core_id);
@@ -1896,6 +1900,12 @@
 		return -1;
 	}
 
+	if (!ast_cc_request_within_limits()) {
+		ast_log(LOG_NOTICE, "CallCompletionRequest failed. Too many requests in the system\n");
+		ast_cc_request_state_change(CC_FAILED, core_instance->core_id, "Too many CC requests\n");
+		return -1;
+	}
+
 	res = ast_cc_request_state_change(CC_CALLER_REQUESTED, core_instance->core_id, "CallCompletionRequest called");
 	cc_unref(core_instance, "Done with CallCompletionRequest");
 	return res;
@@ -2441,6 +2451,11 @@
 
 }
 
+int ast_cc_request_within_limits(void)
+{
+	return cc_request_count < global_cc_max_requests;
+}
+
 int ast_set_cc_interfaces_chanvar(struct ast_channel *chan, const char * const extension)
 {
 	struct ast_datastore *recall_datastore;




More information about the svn-commits mailing list