[asterisk-commits] mmichelson: branch group/CCSS r227843 - /team/group/CCSS/main/ccss.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 4 15:20:08 CST 2009


Author: mmichelson
Date: Wed Nov  4 15:20:04 2009
New Revision: 227843

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=227843
Log:
Found a place where an ast_cc_monitor_failed-like scenario
was present and should be used.


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=227843&r1=227842&r2=227843
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Wed Nov  4 15:20:04 2009
@@ -145,6 +145,16 @@
 static struct cc_core_instance *cc_core_init_instance(struct ast_channel *caller_chan,
 		struct ast_cc_interface_tree *called_tree, const int core_id);
 
+/*
+ * \brief Pass monitor failure up the tree
+ *
+ * When a monitor has a failure, and it is determined that its parent has no
+ * more child links with this particular core_id, we will pass the notification
+ * upwards. If the notification reaches the root monitor, then the CC transaction
+ * will fail completely.
+ */
+static int pass_failure_up(struct ast_cc_monitor *monitor, const int core_id);
+
 static const char *CC_LOGGER_LEVEL_NAME = "CC";
 static int cc_logger_level;
 
@@ -1020,8 +1030,9 @@
 static int internal_cc_available_timer_expire(void *data)
 {
 	struct ast_cc_monitor_link *link = data;
-	struct ast_cc_monitor *parent_monitor = link->parent;
-	struct ast_cc_monitor *child_monitor = link->child;
+	struct ast_cc_monitor_link *child_link_iter;
+	struct ast_cc_monitor *parent_monitor = cc_ref(link->parent, "ref parent link on timer expiration");
+	struct ast_cc_monitor *child_monitor = cc_ref(link->child, "ref child link on timer expiration");
 	int core_id = link->core_id;
 
 	manager_event(EVENT_FLAG_CC, "CCAvailableTimerExpired",
@@ -1043,14 +1054,21 @@
 	link->child_avail_id = -1;
 	destroy_link(link);
 
-	/* Of course, if this link is the only remaining child
-	 * of a parent extension monitor, this means that all the
-	 * other device monitors' available timers have also expired,
-	 * which means we need to request a change to CC_FAILED.
-	 */
-	if (AST_LIST_EMPTY(&parent_monitor->child_links)) {
-		ast_cc_failed(core_id, "All available timers have expired");
-	}
+	cc_unref(child_monitor, "Done pruning child, unref it");
+
+	/* Now we need to see if the parent monitor has any child links
+	 * left with this particular core ID. If not, then it means that
+	 * we need to pass the failure up the tree.
+	 */
+	AST_LIST_TRAVERSE(&parent_monitor->child_links, child_link_iter, next_child) {
+		if (child_link_iter->core_id == core_id) {
+			return 0;
+		}
+	}
+	/* Uh oh, the parent monitor has no more child links with our core_id.
+	 * Pass the failure up. pass_failure_up will unref our reference to parent_monitor.
+	 */
+	pass_failure_up(parent_monitor, core_id);
 	return 0;
 }
 




More information about the asterisk-commits mailing list