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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 20 14:05:53 CST 2010


Author: mmichelson
Date: Wed Jan 20 14:05:52 2010
New Revision: 241628

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=241628
Log:
Write logic for new version of suspend function.

Next thing I need to write is the new way to signal
availability.


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=241628&r1=241627&r2=241628
==============================================================================
--- team/group/CCSS_Monitor_Restructure/main/ccss.c (original)
+++ team/group/CCSS_Monitor_Restructure/main/ccss.c Wed Jan 20 14:05:52 2010
@@ -896,6 +896,10 @@
 	/* The instance of the CC core to which this monitor belongs
 	 */
 	int core_id;
+	/* An indicator that tells whether monitoring of the device
+	 * has been suspended.
+	 */
+	int is_suspended;
 	/* What service was offered by the endpoint. Note that
 	 * this field is completely irrelevant for cc_monitors
 	 * representing dialplan extensions.
@@ -1021,6 +1025,7 @@
 static int cc_generic_monitor_init(struct ast_cc_monitor *monitor, const int core_id);
 static int cc_generic_monitor_request_cc2(struct cc_monitor *monitor, int *available_timer_id);
 static int cc_generic_monitor_suspend(struct ast_cc_monitor *monitor, const int core_id);
+static int cc_generic_monitor_suspend2(struct cc_monitor *monitor);
 static int cc_generic_monitor_status_response(struct ast_cc_monitor *monitor, const int core_id, enum ast_device_state devstate);
 static int cc_generic_monitor_unsuspend(struct ast_cc_monitor *monitor, const int core_id);
 static int cc_generic_monitor_cancel_available_timer(struct ast_cc_monitor *monitor, const int core_id, int *sched_id);
@@ -1032,6 +1037,7 @@
 	.init = cc_generic_monitor_init,
 	.request_cc2 = cc_generic_monitor_request_cc2,
 	.suspend = cc_generic_monitor_suspend,
+	.suspend2 = cc_generic_monitor_suspend2,
 	.status_response = cc_generic_monitor_status_response,
 	.unsuspend = cc_generic_monitor_unsuspend,
 	.cancel_available_timer = cc_generic_monitor_cancel_available_timer,
@@ -1235,6 +1241,39 @@
 	*available_timer_id = ast_sched_thread_add(cc_sched_thread, when * 1000,
 			ast_cc_available_timer_expire, monitor);
 	cc_unref(generic_list, "Finished with monitor instance reference in request cc callback");
+	return 0;
+}
+
+static int cc_generic_monitor_suspend2(struct cc_monitor *monitor)
+{
+	struct generic_monitor_instance_list *generic_list;
+	struct generic_monitor_instance *generic_instance;
+	enum ast_device_state state = ast_device_state(monitor->interface->name);
+
+	/* If the device being suspended is currently in use, then we don't need to
+	 * take any further actions
+	 */
+	if (state != AST_DEVICE_NOT_INUSE && state != AST_DEVICE_UNKNOWN) {
+		return 0;
+	}
+
+	/* If the device is not in use, though, then it may be possible to report the
+	 * device's availability using a different monitor which is monitoring the
+	 * same device
+	 */
+	if (!(generic_list = find_generic_monitor_instance_list(monitor->interface->name))) {
+		return -1;
+	}
+
+	AST_LIST_TRAVERSE(&generic_list->list, generic_instance, next) {
+		if (!generic_instance->monitor->is_suspended) {
+			/* XXX Call function to report availability here. I haven't exactly
+			 * written it yet...
+			 */
+			break;
+		}
+	}
+	cc_unref(generic_list, "Done with generic list in suspend callback");
 	return 0;
 }
 
@@ -2723,6 +2762,8 @@
 		if (monitor_iter->interface->monitor_class == AST_CC_DEVICE_MONITOR) {
 			if (monitor_iter->callbacks->suspend2(monitor_iter)) {
 				AST_DLLIST_REMOVE_CURRENT(next);
+			} else {
+				monitor_iter->is_suspended = 1;
 			}
 		} else if (!has_children(monitor_iter)) {
 			AST_DLLIST_REMOVE_CURRENT(next);




More information about the asterisk-commits mailing list