[svn-commits] murf: branch murf/fast-ast r44615 - in /team/murf/fast-ast/main: pbx.c trb.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Fri Oct 6 13:07:15 MST 2006


Author: murf
Date: Fri Oct  6 15:07:14 2006
New Revision: 44615

URL: http://svn.digium.com/view/asterisk?rev=44615&view=rev
Log:
Until the time is right.


Removed:
    team/murf/fast-ast/main/trb.c
Modified:
    team/murf/fast-ast/main/pbx.c

Modified: team/murf/fast-ast/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast/main/pbx.c?rev=44615&r1=44614&r2=44615&view=diff
==============================================================================
--- team/murf/fast-ast/main/pbx.c (original)
+++ team/murf/fast-ast/main/pbx.c Fri Oct  6 15:07:14 2006
@@ -60,6 +60,7 @@
 #include "asterisk/app.h"
 #include "asterisk/devicestate.h"
 #include "asterisk/stringfields.h"
+#include "trb.h"
 
 /*!
  * \note I M P O R T A N T :
@@ -124,6 +125,8 @@
 	void *data;			/*!< Data to use (arguments) */
 	void (*datad)(void *);		/*!< Data destructor */
 	struct ast_exten *peer;		/*!< Next higher priority with our extension */
+	struct trb_table *peer_tree;    /*!< Priorities list in tree form -- only on the head of the peer list */
+	struct trb_table *peer_label_tree; /*!< labeled priorities in the peer list -- only on the head of the peer list */
 	const char *registrar;		/*!< Registrar */
 	struct ast_exten *next;		/*!< Extension with a greater ID */
 	char stuff[0];
@@ -162,6 +165,7 @@
 struct ast_context {
 	ast_mutex_t lock; 			/*!< A lock to prevent multiple threads from clobbering the context */
 	struct ast_exten *root;			/*!< The root of the list of extensions */
+	struct trb_table *root_tree;            /*!< The root of the list of extensions in threaded red-black tree form */
 	struct ast_context *next;		/*!< Link them together */
 	struct ast_include *includes;		/*!< Include other contexts */
 	struct ast_ignorepat *ignorepats;	/*!< Patterns for which to continue playing dialtone */
@@ -237,6 +241,44 @@
 static int pbx_builtin_sayphonetic(struct ast_channel *, void *);
 int pbx_builtin_setvar(struct ast_channel *, void *);
 static int pbx_builtin_importvar(struct ast_channel *, void *);
+static int trb_compare_contexts(const void *trb_a, const void *trb_b, void *trb_param);
+static int trb_compare_extens(const void *trb_a, const void *trb_b, void *trb_param);
+static int trb_compare_exten_numbers(const void *trb_a, const void *trb_b, void *trb_param);
+static int trb_compare_exten_labels(const void *trb_a, const void *trb_b, void *trb_param);
+
+
+static int trb_compare_contexts(const void *trb_a, const void *trb_b, void *trb_param)
+{
+	struct ast_context *ac = (struct ast_context*)trb_a;
+	struct ast_context *bc = (struct ast_context*)trb_b;
+	return strcmp(ac->name, bc->name);
+}
+
+static int trb_compare_extens(const void *trb_a, const void *trb_b, void *trb_param)
+{
+	struct ast_exten *ac = (struct ast_exten*)trb_a;
+	struct ast_exten *bc = (struct ast_exten*)trb_b;
+	return strcmp(ac->exten, bc->exten);
+}
+
+static int trb_compare_exten_numbers(const void *trb_a, const void *trb_b, void *trb_param)
+{
+	struct ast_exten *ac = (struct ast_exten*)trb_a;
+	struct ast_exten *bc = (struct ast_exten*)trb_b;
+	if (ac->priority < bc->priority)
+		return -1;
+	else if (ac->priority == bc->priority)
+		return 0;
+	else
+		return 1;
+}
+
+static int trb_compare_exten_labels(const void *trb_a, const void *trb_b, void *trb_param)
+{
+	struct ast_exten *ac = (struct ast_exten*)trb_a;
+	struct ast_exten *bc = (struct ast_exten*)trb_b;
+	return strcmp(ac->label, bc->label);
+}
 
 AST_MUTEX_DEFINE_STATIC(globalslock);
 static struct varshead globals = AST_LIST_HEAD_NOLOCK_INIT_VALUE;
@@ -459,6 +501,8 @@
 };
 
 static struct ast_context *contexts = NULL;
+static struct trb_table *contexts_tree = NULL;
+
 AST_MUTEX_DEFINE_STATIC(conlock); 		/*!< Lock for the ast_context list */
 
 static AST_LIST_HEAD_STATIC(apps, ast_app);
@@ -861,11 +905,16 @@
 struct ast_context *ast_context_find(const char *name)
 {
 	struct ast_context *tmp = NULL;
+	struct ast_context item;
+	item->name = name;
 	ast_mutex_lock(&conlock);
+	tmp = trb_find(contexts_tree,&item);
+#ifdef NOTNOW
 	while ( (tmp = ast_walk_contexts(tmp)) ) {
 		if (!name || !strcasecmp(name, tmp->name))
 			break;
 	}
+#endif
 	ast_mutex_unlock(&conlock);
 	return tmp;
 }
@@ -3529,6 +3578,8 @@
 	if (!extcontexts) {
 		ast_mutex_lock(&conlock);
 		local_contexts = &contexts;
+		if (!contexts_tree)
+			contexts_tree = trb_create(trb_compare_contexts, NULL, NULL);
 	} else
 		local_contexts = extcontexts;
 
@@ -3548,11 +3599,13 @@
 		ast_mutex_init(&tmp->macrolock);
 		strcpy(tmp->name, name);
 		tmp->root = NULL;
+		tmp->root_tree = NULL;
 		tmp->registrar = registrar;
 		tmp->next = *local_contexts;
 		tmp->includes = NULL;
 		tmp->ignorepats = NULL;
 		*local_contexts = tmp;
+		trb_insert(contexts_tree, tmp); /*put this context into the tree */
 		if (option_debug)
 			ast_log(LOG_DEBUG, "Registered context '%s'\n", tmp->name);
 		if (option_verbose > 2)



More information about the svn-commits mailing list