[asterisk-commits] mmichelson: branch group/CCSS_Monitor_Restructure r242086 - /team/group/CCSS_...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 21 15:27:01 CST 2010


Author: mmichelson
Date: Thu Jan 21 15:26:57 2010
New Revision: 242086

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=242086
Log:
Fix ast_cc_monitor_count to count monitors correctly.


Modified:
    team/group/CCSS_Monitor_Restructure/main/ccss.c

Modified: team/group/CCSS_Monitor_Restructure/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS_Monitor_Restructure/main/ccss.c?view=diff&rev=242086&r1=242085&r2=242086
==============================================================================
--- team/group/CCSS_Monitor_Restructure/main/ccss.c (original)
+++ team/group/CCSS_Monitor_Restructure/main/ccss.c Thu Jan 21 15:26:57 2010
@@ -903,8 +903,6 @@
 
 static struct ast_cc_monitor_callbacks extension_monitor_cbs = {
 	.type = "extension",
-	.status_response = cc_extension_monitor_status_response,
-	.unsuspend = cc_extension_monitor_unsuspend,
 };
 
 static int cc_generic_monitor_request_cc2(struct cc_monitor *monitor, int *available_timer_id);
@@ -918,7 +916,6 @@
 	.type = "generic",
 	.request_cc2 = cc_generic_monitor_request_cc2,
 	.suspend2 = cc_generic_monitor_suspend2,
-	.status_response = cc_generic_monitor_status_response,
 	.status_response2 = cc_generic_monitor_status_response2,
 	.unsuspend2 = cc_generic_monitor_unsuspend2,
 	.cancel_available_timer2 = cc_generic_monitor_cancel_available_timer2,
@@ -3459,22 +3456,38 @@
 	return res;
 }
 
+struct count_monitors_cb_data {
+	const char *device_name;
+	const char *monitor_type;
+	int count;
+};
+
+static int count_monitors_cb(void *obj, void *arg, int flags)
+{
+	struct cc_core_instance *core_instance = obj;
+	struct count_monitors_cb_data *cb_data = arg;
+	const char *device_name = cb_data->device_name;
+	const char *monitor_type = cb_data->monitor_type;
+	struct cc_monitor *monitor_iter;
+
+	AST_DLLIST_TRAVERSE(core_instance->monitors, monitor_iter, next) {
+		if (!strcmp(monitor_iter->interface->name, device_name) && 
+				!strcmp(monitor_iter->interface->monitor_type, monitor_type)) {
+			cb_data->count++;
+			break;
+		}
+	}
+	return 0;
+}
 
 int ast_cc_monitor_count(const char * const name, const char * const type)
 {
-	struct ast_cc_monitor *monitor;
-	int retval = 0;
-
-	if (!(monitor = find_monitor(name, type))) {
-		/* Can't find it, so there must not be any outstanding requests for it */
-		return 0;
-	}
-
-	retval = monitor->num_requests;
-	cc_unref(monitor, "Unref from ao2_find");
-	return retval;
-}
-
+	struct count_monitors_cb_data data = {.device_name = name, .monitor_type = type,};
+
+	ao2_t_callback(cc_core_instances, OBJ_NODATA, count_monitors_cb, &data, "Counting agents");
+	ast_log_dynamic_level(cc_logger_level, "Counted %d monitors\n", data.count);
+	return data.count;
+}
 
 static struct ast_cc_interface *root_interface_init(void)
 {




More information about the asterisk-commits mailing list