[asterisk-commits] mmichelson: branch group/CCSS r215568 - /team/group/CCSS/main/ccss.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Sep 2 13:45:41 CDT 2009
Author: mmichelson
Date: Wed Sep 2 13:45:38 2009
New Revision: 215568
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=215568
Log:
Flesh out the skeleton for translating an interface tree into monitor
structs a bit.
There are bits left as comments because I haven't yet determined the
best way to find if a monitor for a particular extension/device already
exists. My thinking is that while the graph can ceratainly be searched
using the common DFS and BFS methods, doing so will be incredibly inefficient
and the coding for doing so could be painful, especially if someone figures
out a way to put a loop in the graph. So, instead, I believe what I'll do
is to have the monitors in an ao2_container so that I can easily do an O(1)
lookup when I need to. The tradeoff is that the refcount logic will need
a bit more hand holding, but I'd much rather have that.
Modified:
team/group/CCSS/main/ccss.c
Modified: team/group/CCSS/main/ccss.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=215568&r1=215567&r2=215568
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Wed Sep 2 13:45:38 2009
@@ -826,6 +826,51 @@
* 4. unref the pending_offer's ref to the interface tree. This
* SHOULD cause the interface_tree's destructor to be called.
*/
+
+ struct ast_cc_interface *parent_interface_iterator;
+
+ /* The way that the interface tree is set up, and the way this loop works, the
+ * type of interface that we pull off the front of the list should ALWAYS be
+ * an extension interface
+ */
+ while ((parent_interface_iterator = AST_LIST_REMOVE_HEAD(pending_offer->called_tree, next))) {
+ struct ast_cc_monitor *parent = root_monitor;
+ struct ast_cc_monitor *target = NULL;
+ struct ast_cc_interface *child_interface_iterator;
+
+ ast_assert(strcmp(parent_interface_iterator->monitor_type, "extension") == 0);
+ /* Set target here. It will either be a monitor already in the graph or will
+ * be created if one does not exist. I'm saving this for a bit though since I think
+ * doing a BFS or DFS of the graph for every interface in the pending offer is a
+ * bad idea.
+ *
+ * We can assume here that if we needed to create a new monitor, then it will already
+ * have a monitor link set up between it and parent (which will always be the root_monitor
+ * here).
+ */
+ parent = target;
+ AST_LIST_TRAVERSE_SAFE_BEGIN(pending_offer->called_tree, child_interface_iterator, next) {
+ if (child_interface_iterator->parent_id != parent_interface_iterator->id) {
+ continue;
+ }
+ /* We've found a child of the extension interface we are examining.
+ * We need to see if a monitor exists for THIS interface. So we call
+ * the same finding/creating function that we did before, only this
+ * time, "parent" will be the parent of the newly created/found monitor.
+ */
+ if (strcmp(child_interface_iterator->monitor_type, "extension")) {
+ /* If we aren't dealing with an extension interface, then we
+ * can remove it from the list since we know it will have no
+ * children and we know that a corresponding monitor exists in
+ * the graph.
+ */
+ AST_LIST_REMOVE_CURRENT(next);
+ }
+ }
+ AST_LIST_TRAVERSE_SAFE_END;
+ }
+
+ ao2_unlink(pending_cc_offers, pending_offer);
}
static int cc_monitor_tree_init(const int core_id)
More information about the asterisk-commits
mailing list