[asterisk-commits] anthonyl: branch anthonyl/8267 r48091 - in /team/anthonyl/8267: channels/ inc...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Nov 28 10:15:19 MST 2006


Author: anthonyl
Date: Tue Nov 28 11:15:19 2006
New Revision: 48091

URL: http://svn.digium.com/view/asterisk?view=rev&rev=48091
Log:
a small update for testing

Modified:
    team/anthonyl/8267/channels/chan_iax2.c
    team/anthonyl/8267/include/asterisk/linkedlists.h

Modified: team/anthonyl/8267/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/8267/channels/chan_iax2.c?view=diff&rev=48091&r1=48090&r2=48091
==============================================================================
--- team/anthonyl/8267/channels/chan_iax2.c (original)
+++ team/anthonyl/8267/channels/chan_iax2.c Tue Nov 28 11:15:19 2006
@@ -4212,7 +4212,28 @@
 	ast_cli(fd, "%d of %d threads accounted for with %d dynamic threads\n", threadcount, iaxthreadcount, dynamiccount);
 	return RESULT_SUCCESS;
 }
-
+/* display information about current trunk usage */
+static int iax2_show_trunks(int fd, int argc, char *argv[])
+{
+	struct iax2_peer *peer = NULL;
+	struct iax2_trunk_peer *tpeer;
+	int count = 0;
+	int res = -1;
+	
+	AST_LIST_COUNT(&tpeers, tpeer, list, count);
+
+	ast_cli(fd, "\tTrunks: %i\n", count);
+	
+	AST_LIST_LOCK(&tpeers);
+	AST_LIST_TRAVERSE_SAFE_BEGIN(&tpeers, tpeer, list) {
+		ast_cli(fd, "\tMemory Inuse: %i\n", tpeer->trunkdatalen);
+		ast_cli(fd, "\tMemory Allocated: %i\n", tpeer->trunkdataalloc);
+	}
+	AST_LIST_TRAVERSE_SAFE_END
+	AST_LIST_UNLOCK(&tpeers);
+	
+	return RESULT_SUCCESS;
+}
 static int iax2_show_peers(int fd, int argc, char *argv[])
 {
 	return __iax2_show_peers(0, fd, NULL, argc, argv);
@@ -5898,7 +5919,8 @@
 	struct ast_iax2_meta_hdr *meta;
 	struct ast_iax2_meta_trunk_hdr *mth;
 	int calls = 0;
-	
+	char *tmp;
+
 	/* Point to frame */
 	fr = (struct iax_frame *)tpeer->trunkdata;
 	/* Point to meta data */
@@ -5929,6 +5951,14 @@
 		/* Reset transmit trunk side data */
 		tpeer->trunkdatalen = 0;
 		tpeer->calls = 0;
+		/* it may also be a good idea to shrink this back down to the default */
+		if (trunkrealloc) {
+			if( !(tmp = ast_realloc(tpeer->trunkdata,DEFAULT_TRUNKDATA + IAX2_TRUNK_PREFACE))) {
+				return -1;	
+			}
+			tpeer->trunkdata = tmp;
+			tpeer->trunkdataalloc = DEFAULT_TRUNKDATA;
+		}	
 	}
 	if (res < 0)
 		return res;
@@ -9718,6 +9748,10 @@
 "Usage: iax2 debug trunk\n"
 "       Requests current status of IAX trunking\n";
 
+static char show_trunks_usage[] = 
+"Usage: iax2 show trunks\n"
+"	Display IAX trunking stats\n";
+
 static char no_debug_trunk_usage[] =
 "Usage: iax2 nodebug trunk\n"
 "       Requests current status of IAX trunking\n";
@@ -9776,7 +9810,11 @@
 	{ { "iax2", "show", "stats", NULL },
 	iax2_show_stats, "Display IAX statistics",
 	show_stats_usage },
-
+	
+	{ { "iax2", "show", "trunks", NULL},
+	iax2_show_trunks, "Show IAX trunk statistics",
+	show_trunks_usage},
+	
 	{ { "iax2", "show", "threads", NULL },
 	iax2_show_threads, "Display IAX helper thread info",
 	show_threads_usage },

Modified: team/anthonyl/8267/include/asterisk/linkedlists.h
URL: http://svn.digium.com/view/asterisk/team/anthonyl/8267/include/asterisk/linkedlists.h?view=diff&rev=48091&r1=48090&r2=48091
==============================================================================
--- team/anthonyl/8267/include/asterisk/linkedlists.h (original)
+++ team/anthonyl/8267/include/asterisk/linkedlists.h Tue Nov 28 11:15:19 2006
@@ -455,6 +455,12 @@
 
 #define AST_RWLIST_TRAVERSE AST_LIST_TRAVERSE
 
+/* i want to be able to get the number of elements in any linked list from one macro */
+#define AST_LIST_COUNT(head,var,field,count)		\
+	for((var) = (head)->first; (var); (var) = (var)->field.next) \
+		(count)++;
+
+
 /*!
   \brief Loops safely over (traverses) the entries in a list.
   \param head This is a pointer to the list head structure



More information about the asterisk-commits mailing list