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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Sep 23 12:47:13 CDT 2009


Author: mmichelson
Date: Wed Sep 23 12:47:07 2009
New Revision: 219896

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=219896
Log:
Part 1 of handling max_cc_monitors.

The next part will be to actually increment and decrement
the num_requests portion of an ast_cc_monitor as needed.
This should be fairly easy, since the number of requests
will correspond to the number of parent links a monitor has.

Create a link, increase num_requests.
Destroy a link, decrease num_requests.


Modified:
    team/group/CCSS/include/asterisk/ccss.h
    team/group/CCSS/main/ccss.c
    team/group/CCSS/main/channel.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=219896&r1=219895&r2=219896
==============================================================================
--- team/group/CCSS/include/asterisk/ccss.h (original)
+++ team/group/CCSS/include/asterisk/ccss.h Wed Sep 23 12:47:07 2009
@@ -548,6 +548,7 @@
 	 */
 	struct ast_cc_monitor_link *saved_link;
 	struct ast_cc_interface *interface;
+	int num_requests;
 };
 
 struct ast_cc_monitor_callbacks {
@@ -745,7 +746,7 @@
 int ast_cc_request_state_change(enum ast_cc_state state, const int core_id, const char *debug);
 
 /*!
- * \sinxe 1.6.4
+ * \since 1.6.4
  * \brief Alert the core that a device being monitored has become available.
  *
  * The code in the core will take care of making sure that the information gets passed
@@ -756,6 +757,16 @@
  * \retval -1 Request could not be queued
  */
 int ast_cc_monitor_announce_availability(struct ast_cc_monitor *monitor);
+
+/*!
+ * \since 1.6.4
+ * \brief Return the number of outstanding CC requests to a specific device
+ *
+ * \param name The name of the monitored device
+ * \param type The type of the monitored device (e.g. "generic")
+ * \return The number of CC requests for the monitor
+ */
+int ast_cc_monitor_count(const char * const name, const char * const type);
 
 /*!
  * \since 1.6.4

Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=219896&r1=219895&r2=219896
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Wed Sep 23 12:47:07 2009
@@ -1709,6 +1709,25 @@
 	return;
 }
 
+int ast_cc_monitor_count(const char * const name, const char * const type)
+{
+	struct ast_cc_monitor *monitor;
+	struct ast_cc_monitor finder;
+	struct ast_cc_interface *finder_interface = alloca(sizeof(*finder_interface) + strlen(name));
+	int retval = 0;
+
+	finder.interface = finder_interface;
+
+	if (!(monitor = ao2_t_find(cc_monitors, &finder, OBJ_POINTER, "Trying to find monitor for counting"))) {
+		/* Can't find it, so there must not be any outstanding requests for it */
+		return 0;
+	}
+
+	retval = monitor->num_requests;
+	ao2_t_ref(monitor, -1, "Unref from ao2_find");
+	return retval;
+}
+
 int ast_cc_monitor_register(const struct ast_cc_monitor_callbacks *callbacks)
 {
 	struct cc_monitor_backend *backend = ast_calloc(1, sizeof(*backend));

Modified: team/group/CCSS/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/channel.c?view=diff&rev=219896&r1=219895&r2=219896
==============================================================================
--- team/group/CCSS/main/channel.c (original)
+++ team/group/CCSS/main/channel.c Wed Sep 23 12:47:07 2009
@@ -7154,9 +7154,21 @@
 {
 	struct ast_frame frame = {.frametype = AST_FRAME_CONTROL, .subclass = AST_CONTROL_CC };
 	struct ast_control_cc_payload *payload;
+	char chan_name[AST_CHANNEL_NAME];
+	char *dash;
 
 	if (!(payload = ast_calloc(1, sizeof(*payload)))) {
 		return -1;
+	}
+
+	ast_copy_string(chan_name, chan->name, sizeof(chan_name));
+	if ((dash = strrchr(chan_name, '-'))) {
+		*dash = '\0';
+	}
+
+	if (ast_cc_monitor_count(chan_name, monitor_type) >= ast_get_cc_max_monitors(ast_channel_get_cc_config_params(chan))) {
+		ast_log(LOG_NOTICE, "Not queuing a CC frame for channel %s since it already has its maximum monitors allocated\n");
+		return 0;
 	}
 
 	payload->monitor_type = monitor_type;




More information about the asterisk-commits mailing list