[asterisk-commits] mmichelson: branch group/CCSS r219787 - in /team/group/CCSS: apps/ include/as...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Sep 21 14:02:45 CDT 2009


Author: mmichelson
Date: Mon Sep 21 14:02:40 2009
New Revision: 219787

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=219787
Log:
Get CC configuration parameters onto the monitor.

This is necessary so that decisions can be made regarding
the cc_max_monitors option, and the cc_available_timer can
be armed easily.

In making these changes, I've noticed a couple of things to
improve on:

1. ast_cc_interface and ast_cc_monitor have a lot of overlap.
I am going to isolate the common elements into a single struct
for ease-of-use and ease-of-reading.

2. There is a lot of allocation and copying of ast_cc_config_params.
It may be a better idea to make use of reference-counting instead.

I can hopefully knock both of these out in the next couple of commits.


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

Modified: team/group/CCSS/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/apps/app_dial.c?view=diff&rev=219787&r1=219786&r2=219787
==============================================================================
--- team/group/CCSS/apps/app_dial.c (original)
+++ team/group/CCSS/apps/app_dial.c Mon Sep 21 14:02:40 2009
@@ -1904,6 +1904,11 @@
 		return NULL;
 	}
 
+	if (!(cc_interface->config_params = ast_cc_config_params_init())) {
+		ast_free(cc_interface);
+		return NULL;
+	}
+
 	strcpy(cc_interface->name, name);
 	cc_interface->id = ast_atomic_fetchadd_int(&dial_cc_interface_counter, +1);
 	cc_interface->parent_id = parent_id;
@@ -1914,6 +1919,7 @@
 	cc_interface->monitor_type = cc_data->monitor_type;
 	cc_interface->service_offered = cc_data->service;
 	cc_interface->monitor_class = AST_CC_DEVICE_MONITOR;
+	ast_cc_copy_config_params(cc_interface->config_params, cc_data->config_params);
 	ast_log(LOG_NOTICE, "Created a device cc interface for '%s' with id %d and parent %d\n", cc_interface->name, cc_interface->id, cc_interface->parent_id);
 	return cc_interface;
 }

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=219787&r1=219786&r2=219787
==============================================================================
--- team/group/CCSS/include/asterisk/ccss.h (original)
+++ team/group/CCSS/include/asterisk/ccss.h Mon Sep 21 14:02:40 2009
@@ -121,6 +121,7 @@
 struct ast_control_cc_payload {
 	enum ast_cc_service_type service;
 	const char *monitor_type;
+	struct ast_cc_config_params *config_params;
 };
 
 /* Forward declaration. Struct is in main/ccss.c */
@@ -423,6 +424,10 @@
 	 * no reason to make a new copy.
 	 */
 	const char *monitor_type;
+	/*!
+	 * The configuration parameters used for this interface
+	 */
+	struct ast_cc_config_params *config_params;
 	AST_LIST_ENTRY(ast_cc_interface) next;
 	/* The name of the interface/extension. local channels will
 	 * have 'exten at context' for a name. Other channel types will
@@ -515,9 +520,14 @@
 	 * link. This way, the monitor is sure to continue
 	 * communicating with the same upstream extension
 	 * monitor even if a lower-weighted link should
-	 * become unsuspended
+	 * become unsuspended.
 	 */
 	struct ast_cc_monitor_link *saved_link;
+	/*!
+	 * CC configuration parameters to use for this monitored
+	 * device.
+	 */
+	struct ast_cc_config_params *config_params;
 	/*! The name of the device/extension being monitored */
 	char name[1];
 };

Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=219787&r1=219786&r2=219787
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Mon Sep 21 14:02:40 2009
@@ -860,7 +860,8 @@
 }
 
 static struct ast_cc_monitor *cc_monitor_instance_init(enum ast_cc_monitor_class monitor_class, 
-		const char * const callback_type, const char * const monitor_name, const int core_id)
+		const char * const callback_type, const char * const monitor_name, const int core_id,
+		const struct ast_cc_config_params *config_params)
 {
 	struct ast_cc_monitor *monitor;
 	const struct ast_cc_monitor_callbacks *callbacks = find_monitor_callbacks(callback_type);
@@ -871,6 +872,14 @@
 		return NULL;
 	}
 
+	if (config_params) {
+		if (!(monitor->config_params = ast_cc_config_params_init())) {
+			ao2_ref(monitor, -1);
+			return NULL;
+		}
+
+		ast_cc_copy_config_params(monitor->config_params, config_params);
+	}
 	monitor->monitor_class = monitor_class;
 	strcpy(monitor->name, monitor_name);
 	monitor->callbacks = callbacks;
@@ -896,7 +905,7 @@
 	if ((new_monitor = ao2_t_find(cc_monitors, finder, OBJ_POINTER, "Trying to find a specific monitor"))) {
 		ast_log(LOG_NOTICE, "Found monitor %s in tree. Re-using\n", new_monitor->name);
 	} else if (!(new_monitor = cc_monitor_instance_init(interface->monitor_class, 
-					interface->monitor_type, interface->name, core_id))) {
+					interface->monitor_type, interface->name, core_id, interface->config_params))) {
 		return NULL;
 	}
 
@@ -1745,7 +1754,7 @@
 	 * extension monitor callbacks since the gist of those will be to traverse
 	 * their child links and call each of their children's callbacks
 	 */
-	if (!(root_monitor = cc_monitor_instance_init(AST_CC_ROOT_MONITOR, "extension", "root", -1))) {
+	if (!(root_monitor = cc_monitor_instance_init(AST_CC_ROOT_MONITOR, "extension", "root", -1, NULL))) {
 		return -1;
 	}
 	ast_log(LOG_NOTICE, "Successfully created the root CC monitor\n");

Modified: team/group/CCSS/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/channel.c?view=diff&rev=219787&r1=219786&r2=219787
==============================================================================
--- team/group/CCSS/main/channel.c (original)
+++ team/group/CCSS/main/channel.c Mon Sep 21 14:02:40 2009
@@ -7161,6 +7161,11 @@
 
 	payload->monitor_type = monitor_type;
 	payload->service = service;
+	if (!(payload->config_params = ast_cc_config_params_init())) {
+		ast_free(payload);
+		return -1;
+	}
+	ast_cc_copy_config_params(payload->config_params, ast_channel_get_cc_config_params(chan));
 	ast_log(LOG_NOTICE, "Going to queue a frame with payload %s, %d\n", payload->monitor_type, payload->service);
 	frame.mallocd = AST_MALLOCD_DATA;
 	frame.data.ptr = payload;




More information about the asterisk-commits mailing list