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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 20 11:07:03 CST 2010


Author: mmichelson
Date: Wed Jan 20 11:07:01 2010
New Revision: 241580

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=241580
Log:
Get structures in place for generic device monitoring.


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=241580&r1=241579&r2=241580
==============================================================================
--- team/group/CCSS_Monitor_Restructure/main/ccss.c (original)
+++ team/group/CCSS_Monitor_Restructure/main/ccss.c Wed Jan 20 11:07:01 2010
@@ -1027,19 +1027,56 @@
 	.instance_destructor = cc_generic_monitor_instance_destructor,
 };
 
+struct ao2_container *generic_monitors;
+
+struct generic_monitor_instance {
+	struct cc_monitor *monitor;
+	AST_LIST_ENTRY(next);
+};
+
+struct generic_monitor_instance_list {
+	const char *device_name;
+	enum ast_device_state current_state;
+	struct ast_event_sub *sub;
+	AST_LIST_HEAD_NOLOCK(, generic_monitor_instance) list;
+};
+
 /*!
  * \brief private data for generic device monitor
  */
 struct generic_monitor_pvt {
 	/*!
-	 * Handle for event subscription to device state
-	 */
+	 * We need the device name during destruction so we
+	 * can find the appropriate item to destroy.
+	 */
+	const char *device_name;
+	/*!
+	 * We need the core ID for similar reasons. Once we
+	 * find the appropriate item in our ao2_container, we
+	 * need to remove the appropriate cc_monitor from the
+	 * list of monitors.
+	 */
+	int core_id;
+	/* XXX LEFTOVER PARAMETERS FROM OLD DESIGN. REMOVE ONCE
+	 * THEY ARE NO LONGER NEEDED FOR SUCCESSFUL COMPILATION
+	 */
+	enum ast_device_state current_state;
 	struct ast_event_sub *sub;
-	/*!
-	 * Cached device state for this monitor
-	 */
-	enum ast_device_state current_state;
 };
+
+static int generic_monitor_hash_fn(const void *obj, const int flags)
+{
+	const struct generic_monitor_instance_list *generic_list = obj;
+	return ast_str_hash(generic_list->device_name);
+}
+
+static int generic_monitor_cmp_fn(void *obj, void *arg, int flags)
+{
+	const struct generic_monitor_instance_list *generic_list1 = obj;
+	const struct generic_monitor_instance_list *generic_list2 = arg;
+
+	return !strcmp(generic_list1->device_name, generic_list2->device_name) ? CMP_MATCH | CMP_STOP : 0;
+}
 
 static int cc_generic_monitor_init(struct ast_cc_monitor *monitor, const int core_id)
 {
@@ -3775,6 +3812,11 @@
 					"Create monitor container"))) {
 		return -1;
 	}
+	if (!(generic_monitors = ao2_t_container_alloc(CC_CORE_INSTANCES_BUCKETS,
+					generic_monitor_hash_fn, generic_monitor_cmp_fn,
+					"Create generic monitor container"))) {
+		return -1;
+	}
 	if (!(cc_core_taskprocessor = ast_taskprocessor_get("CCSS core", TPS_REF_DEFAULT))) {
 		return -1;
 	}




More information about the asterisk-commits mailing list