[svn-commits] mmichelson: branch group/CCSS_Monitor_Restructure r241365 - in /team/group/CC...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jan 19 16:58:01 CST 2010


Author: mmichelson
Date: Tue Jan 19 16:57:58 2010
New Revision: 241365

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=241365
Log:
Change some more callbacks to the new versions.


Modified:
    team/group/CCSS_Monitor_Restructure/include/asterisk/ccss.h
    team/group/CCSS_Monitor_Restructure/main/ccss.c

Modified: team/group/CCSS_Monitor_Restructure/include/asterisk/ccss.h
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS_Monitor_Restructure/include/asterisk/ccss.h?view=diff&rev=241365&r1=241364&r2=241365
==============================================================================
--- team/group/CCSS_Monitor_Restructure/include/asterisk/ccss.h (original)
+++ team/group/CCSS_Monitor_Restructure/include/asterisk/ccss.h Tue Jan 19 16:57:58 2010
@@ -576,6 +576,7 @@
 	 * \retval -1 on failure.
 	 */
 	int (*suspend)(struct ast_cc_monitor *monitor, const int core_id);
+	int (*suspend2)(struct cc_monitor *monitor);
 	/*!
 	 * \brief Status response to an ast_cc_monitor_status_request().
 	 *
@@ -606,6 +607,7 @@
 	 * \retval -1 on failure.
 	 */
 	int (*unsuspend)(struct ast_cc_monitor *monitor, const int core_id);
+	int (*unsuspend2)(struct cc_monitor *monitor);
 	/*!
 	 * \brief Cancel the running available timer.
 	 *
@@ -624,6 +626,7 @@
 	 * \retval -1 on failure.
 	 */
 	int (*cancel_available_timer)(struct ast_cc_monitor *monitor, const int core_id, int *sched_id);
+	int (*cancel_available_timer2)(struct cc_monitor *monitor, int *sched_id);
 	/*!
 	 * \brief Destroy private data on the monitor.
 	 *

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=241365&r1=241364&r2=241365
==============================================================================
--- team/group/CCSS_Monitor_Restructure/main/ccss.c (original)
+++ team/group/CCSS_Monitor_Restructure/main/ccss.c Tue Jan 19 16:57:58 2010
@@ -2623,6 +2623,25 @@
 	return 0;
 }
 
+static void unsuspend(struct cc_core_instance *core_instance)
+{
+	struct cc_monitor *monitor_iter;
+	AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_BEGIN(core_instance->monitors, monitor_iter, next) {
+		if (monitor_iter->interface->monitor_class == AST_CC_DEVICE_MONITOR) {
+			if (monitor_iter->callbacks->unsuspend2(monitor_iter)) {
+				AST_DLLIST_REMOVE_CURRENT(next);
+			}
+		} else if (!has_children(monitor_iter)) {
+			AST_DLLIST_REMOVE_CURRENT(next);
+		}
+	}
+	AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_END;
+
+	if (AST_DLLIST_EMPTY(core_instance->monitors)) {
+		ast_cc_failed(core_instance->core_id, "All device monitors failed to unsuspend CC");
+	}
+}
+
 static int cc_active(struct cc_core_instance *core_instance, struct cc_state_change_args *args, enum cc_state previous_state)
 {
 	/* Either
@@ -2639,6 +2658,7 @@
 			"CoreID: %d\r\n"
 			"Caller: %s\r\n",
 			core_instance->core_id, core_instance->agent->interface);
+		unsuspend(core_instance);
 		core_instance->monitor->callbacks->unsuspend(core_instance->monitor, core_instance->core_id);
 	}
 	/* Not possible for previous_state to be anything else due to the is_state_change_valid check at the beginning */
@@ -2649,6 +2669,25 @@
 {
 	core_instance->agent->callbacks->callee_available(core_instance->agent);
 	return 0;
+}
+
+static void suspend(struct cc_core_instance *core_instance)
+{
+	struct cc_monitor *monitor_iter;
+	AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_BEGIN(core_instance->monitors, monitor_iter, next) {
+		if (monitor_iter->interface->monitor_class == AST_CC_DEVICE_MONITOR) {
+			if (monitor_iter->callbacks->suspend2(monitor_iter)) {
+				AST_DLLIST_REMOVE_CURRENT(next);
+			}
+		} else if (!has_children(monitor_iter)) {
+			AST_DLLIST_REMOVE_CURRENT(next);
+		}
+	}
+	AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_END;
+
+	if (AST_DLLIST_EMPTY(core_instance->monitors)) {
+		ast_cc_failed(core_instance->core_id, "All device monitors failed to suspend CC");
+	}
 }
 
 static int cc_caller_busy(struct cc_core_instance *core_instance, struct cc_state_change_args *args, enum cc_state previous_state)
@@ -2656,7 +2695,7 @@
 	/* Callee was available, but caller was busy, call agent's begin_monitoring callback
 	 * and call monitor's suspend callback.
 	 */
-	core_instance->monitor->callbacks->suspend(core_instance->monitor, core_instance->core_id);
+	suspend(core_instance);
 	core_instance->agent->callbacks->start_monitoring(core_instance->agent);
 	manager_event(EVENT_FLAG_CC, "CCCallerStartMonitoring",
 		"CoreID: %d\r\n"
@@ -2665,11 +2704,30 @@
 	return 0;
 }
 
+static void cancel_available_timer(struct cc_core_instance *core_instance)
+{
+	struct cc_monitor *monitor_iter;
+	AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_BEGIN(core_instance->monitors, monitor_iter, next) {
+		if (monitor_iter->interface->monitor_class == AST_CC_DEVICE_MONITOR) {
+			if (monitor_iter->callbacks->cancel_available_timer2(monitor_iter, &monitor_iter->available_timer_id)) {
+				AST_DLLIST_REMOVE_CURRENT(next);
+			}
+		} else if (!has_children(monitor_iter)) {
+			AST_DLLIST_REMOVE_CURRENT(next);
+		}
+	}
+	AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_END;
+
+	if (AST_DLLIST_EMPTY(core_instance->monitors)) {
+		ast_cc_failed(core_instance->core_id, "All device monitors failed to cancel their available timers");
+	}
+}
+
 static int cc_recalling(struct cc_core_instance *core_instance, struct cc_state_change_args *args, enum cc_state previous_state)
 {
 	/* Both caller and callee are available, call agent's recall callback
 	 */
-	core_instance->monitor->callbacks->cancel_available_timer(core_instance->monitor, core_instance->core_id, NULL);
+	cancel_available_timer(core_instance);
 	manager_event(EVENT_FLAG_CC, "CCCallerRecalling",
 		"CoreID: %d\r\n"
 		"Caller: %s\r\n",




More information about the svn-commits mailing list