[svn-commits] mmichelson: branch group/CCSS r227928 - /team/group/CCSS/main/ccss.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Nov 4 16:33:14 CST 2009


Author: mmichelson
Date: Wed Nov  4 16:33:11 2009
New Revision: 227928

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=227928
Log:
Convert the ast_cc_available_timer_expired function to use the pass_failure_up function.

Fixed some bugs as well. Cool.


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=227928&r1=227927&r2=227928
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Wed Nov  4 16:33:11 2009
@@ -1027,58 +1027,11 @@
 	return;
 }
 
-static int internal_cc_available_timer_expire(void *data)
-{
-	struct ast_cc_monitor_link *link = data;
-	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",
-		"CoreID: %d\r\n"
-		"Callee: %s\r\n",
-		link->core_id, child_monitor->interface->name);
-	/* When an available_timer expires, We just need to
-	 * prune the monitor from the tree. Just because one
-	 * available timer expires doesn't mean we should give
-	 * up monitoring other devices.
-	 */
-	prune_links(child_monitor, core_id, link);
-	AST_LIST_REMOVE(&parent_monitor->child_links, link, next_child);
-	/* We need to set the scheduler ID to -1 here so that
-	 * the cancel_available_timer callback will know not to
-	 * try to delete the scheduler entry while the scheduler
-	 * callback is running.
-	 */
+int ast_cc_available_timer_expire(const void *data)
+{
+	struct ast_cc_monitor_link *link = (struct ast_cc_monitor_link *) data;
 	link->child_avail_id = -1;
-	destroy_link(link);
-
-	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;
-}
-
-int ast_cc_available_timer_expire(const void *data)
-{
-	/* It is essential that the link-pruning and destruction process happens in
-	 * the core CC thread, so we need to hand this off to the taskprocessor
-	 */
-	ast_taskprocessor_push(cc_core_taskprocessor, internal_cc_available_timer_expire, (void *) data);
-	return 0;
+	return ast_cc_monitor_failed(link->core_id, link->child->interface->name, link->child->interface->monitor_type);
 }
 
 
@@ -2951,7 +2904,6 @@
 			AST_LIST_REMOVE_CURRENT(next_parent);
 			parent_link_iter->child->callbacks->cancel_available_timer(parent_link_iter->parent, 
 					core_id, &parent_link_iter->child_avail_id);
-			destroy_link(parent_link_iter);
 			break;
 		}
 	}
@@ -2959,6 +2911,9 @@
 
 	/* If this assertion fails, something is terribly wrong */
 	ast_assert(parent_monitor != NULL);
+	ast_assert(parent_link_iter != NULL);
+	AST_LIST_REMOVE(&parent_monitor->child_links, parent_link_iter, next_child);
+	destroy_link(parent_link_iter);
 
 	if (AST_LIST_EMPTY(&monitor->child_links) && AST_LIST_EMPTY(&monitor->parent_links)) {
 		/* No more links have references to this monitor, so unlink it */
@@ -3016,9 +2971,11 @@
 		 */
 		ast_log_dynamic_level(cc_logger_level, "Ignoring monitor failure since we are in the recalling state\n");
 		cc_unref(monitor, "In recall state, no need to propagate failure. Unref");
+		cc_unref(core_instance, "In recall state, unref local ref of core_instance");
 		return 0;
 	}
 
+	cc_unref(core_instance, "Done with ref of core instance in cc_monitor_failed");
 	return pass_failure_up(monitor, core_id);
 }
 
@@ -3299,27 +3256,22 @@
 		return -1;
 	}
 
-	ast_log(LOG_NOTICE, "Successfully created pending offers container\n");
 	if (!(cc_core_instances = ao2_t_container_alloc(CC_CORE_INSTANCES_BUCKETS,
 					cc_core_instance_hash_fn, cc_core_instance_cmp_fn,
 					"Create core instance container"))) {
 		return -1;
 	}
-	ast_log(LOG_NOTICE, "Successfully created core instancess container\n");
 	if (!(cc_monitors = ao2_t_container_alloc(CC_CORE_INSTANCES_BUCKETS,
 					cc_monitor_hash_fn, cc_monitor_cmp_fn,
 					"Create monitor container"))) {
 		return -1;
 	}
-	ast_log(LOG_NOTICE, "Successfully created monitors  container\n");
 	if (!(cc_core_taskprocessor = ast_taskprocessor_get("CCSS core", TPS_REF_DEFAULT))) {
 		return -1;
 	}
-	ast_log(LOG_NOTICE, "Successfully started CC task processor\n");
 	if (!(cc_sched_thread = ast_sched_thread_create())) {
 		return -1;
 	}
-	ast_log(LOG_NOTICE, "Successfully created CC sched_thread context\n");
 	res = ast_register_application2(ccreq_app, ccreq_exec, NULL, NULL, NULL);
 	res |= ast_register_application2(cccancel_app, cccancel_exec, NULL, NULL, NULL);
 	res |= ast_cc_monitor_register(&extension_monitor_cbs);
@@ -3332,7 +3284,6 @@
 	if (!(root_monitor = cc_monitor_instance_init(root_interface, -1))) {
 		return -1;
 	}
-	ast_log(LOG_NOTICE, "Successfully created the root CC monitor\n");
 	ast_cli_register_multiple(cc_cli, ARRAY_LEN(cc_cli));
 	cc_logger_level = ast_logger_register_level(CC_LOGGER_LEVEL_NAME);
 	/* FOR THE LOVE OF GOD DO NOT SET root_monitor TO NULL HERE */




More information about the svn-commits mailing list