[asterisk-commits] mmichelson: branch group/CCSS r222798 - /team/group/CCSS/main/ccss.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Oct 8 11:39:02 CDT 2009
Author: mmichelson
Date: Thu Oct 8 11:38:59 2009
New Revision: 222798
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=222798
Log:
Create a find_monitor function to cut back on
duplicated code.
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=222798&r1=222797&r2=222798
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Thu Oct 8 11:38:59 2009
@@ -1517,19 +1517,25 @@
return monitor;
}
+static struct ast_cc_monitor *find_monitor(const char * const name, const char * const type)
+{
+ struct ast_cc_interface *finder_interface = alloca(sizeof(*finder_interface) + strlen(name));
+ struct ast_cc_monitor finder;
+
+ strcpy(finder_interface->name, name);
+ finder_interface->monitor_type = type;
+ finder.interface = finder_interface;
+
+ return ao2_t_find(cc_monitors, &finder, OBJ_POINTER, "Trying to find specific monitor");
+}
+
static struct ast_cc_monitor *find_or_create_monitor(struct ast_cc_monitor *parent, struct ast_cc_tree_item *tree_item, const int core_id)
{
struct ast_cc_monitor *new_monitor;
struct ast_cc_monitor_link *new_link;
struct ast_cc_interface *interface = tree_item->interface;
- struct ast_cc_interface *finder_interface = alloca(sizeof(*finder_interface) + strlen(interface->name));
- struct ast_cc_monitor finder;
-
- strcpy(finder_interface->name, interface->name);
- finder_interface->monitor_type = interface->monitor_type;
- finder.interface = finder_interface;
-
- if ((new_monitor = ao2_t_find(cc_monitors, &finder, OBJ_POINTER, "Trying to find a specific monitor"))) {
+
+ if ((new_monitor = find_monitor(interface->name, interface->monitor_type))) {
ast_log(LOG_NOTICE, "Found monitor %s in tree. Re-using\n", new_monitor->interface->name);
} else if (!(new_monitor = cc_monitor_instance_init(interface, core_id))) {
return NULL;
@@ -2363,15 +2369,9 @@
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;
- strcpy(finder_interface->name, name);
- finder_interface->monitor_type = type;
- finder.interface = finder_interface;
-
- if (!(monitor = ao2_t_find(cc_monitors, &finder, OBJ_POINTER, "Trying to find monitor for counting"))) {
+ if (!(monitor = find_monitor(name, type))) {
/* Can't find it, so there must not be any outstanding requests for it */
return 0;
}
More information about the asterisk-commits
mailing list