[asterisk-commits] russell: branch russell/iax2_find_callno r114885 - in /team/russell/iax2_find...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 30 09:50:47 CDT 2008


Author: russell
Date: Wed Apr 30 09:50:47 2008
New Revision: 114885

URL: http://svn.digium.com/view/asterisk?view=rev&rev=114885
Log:
sync with trunk again

Modified:
    team/russell/iax2_find_callno/   (props changed)
    team/russell/iax2_find_callno/channels/chan_iax2.c
    team/russell/iax2_find_callno/channels/iax2.h

Propchange: team/russell/iax2_find_callno/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/russell/iax2_find_callno/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Apr 30 09:50:47 2008
@@ -1,1 +1,1 @@
-/trunk:1-114882
+/trunk:1-114884

Modified: team/russell/iax2_find_callno/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/russell/iax2_find_callno/channels/chan_iax2.c?view=diff&rev=114885&r1=114884&r2=114885
==============================================================================
--- team/russell/iax2_find_callno/channels/chan_iax2.c (original)
+++ team/russell/iax2_find_callno/channels/chan_iax2.c Wed Apr 30 09:50:47 2008
@@ -118,9 +118,6 @@
 #define DEFAULT_RETRY_TIME 1000
 #define MEMORY_SIZE 100
 #define DEFAULT_DROP 3
-/* Flag to use with trunk calls, keeping these calls high up.  It halves our effective use
-   but keeps the division between trunked and non-trunked better. */
-#define TRUNK_CALL_START	0x4000
 
 #define DEBUG_SUPPORT
 
@@ -152,8 +149,6 @@
 static int max_retries = 4;
 static int ping_time = 21;
 static int lagrq_time = 10;
-static int maxtrunkcall = TRUNK_CALL_START;
-static int maxnontrunkcall = 1;
 static int maxjitterbuffer=1000;
 static int resyncthreshold=1000;
 static int maxjitterinterps=10;
@@ -864,7 +859,7 @@
  * The index used here is the same as used in the iaxs array.  It is the
  * local call number for the associated pvt struct.
  */
-static ast_mutex_t iaxsl[IAX_MAX_CALLS];
+static ast_mutex_t iaxsl[ARRAY_LEN(iaxs)];
 
 /*!
  * \brief The last time a call number was used
@@ -885,7 +880,14 @@
  * The specified time that we must wait before reusing a local call number is
  * defined as MIN_REUSE_TIME, with a default of 60 seconds.
  */
-static struct timeval lastused[IAX_MAX_CALLS];
+static struct timeval lastused[ARRAY_LEN(iaxs)];
+
+/* Flag to use with trunk calls, keeping these calls high up.  It halves our effective use
+   but keeps the division between trunked and non-trunked better. */
+#define TRUNK_CALL_START	ARRAY_LEN(iaxs) / 2
+
+static int maxtrunkcall = TRUNK_CALL_START;
+static int maxnontrunkcall = 1;
 
 static enum ast_bridge_result iax2_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms);
 static int expire_registry(const void *data);
@@ -1495,11 +1497,14 @@
 {
 	int max = TRUNK_CALL_START;
 	int x;
+
 	/* XXX Prolly don't need locks here XXX */
-	for (x=TRUNK_CALL_START;x<IAX_MAX_CALLS - 1; x++) {
-		if (iaxs[x])
+	for (x = TRUNK_CALL_START; x < ARRAY_LEN(iaxs) - 1; x++) {
+		if (iaxs[x]) {
 			max = x + 1;
-	}
+		}
+	}
+
 	maxtrunkcall = max;
 	if (iaxdebug)
 		ast_debug(1, "New max trunk callno is %d\n", max);
@@ -1532,7 +1537,7 @@
 		ast_log(LOG_WARNING, "Call %d is already a trunk\n", callno);
 		return -1;
 	}
-	for (x=TRUNK_CALL_START;x<IAX_MAX_CALLS - 1; x++) {
+	for (x = TRUNK_CALL_START; x < ARRAY_LEN(iaxs) - 1; x++) {
 		ast_mutex_lock(&iaxsl[x]);
 		if (!iaxs[x] && ((now.tv_sec - lastused[x].tv_sec) > MIN_REUSE_TIME)) {
 			iaxs[x] = iaxs[callno];
@@ -1552,7 +1557,7 @@
 		}
 		ast_mutex_unlock(&iaxsl[x]);
 	}
-	if (x >= IAX_MAX_CALLS - 1) {
+	if (x >= ARRAY_LEN(iaxs) - 1) {
 		ast_log(LOG_WARNING, "Unable to trunk call: Insufficient space\n");
 		return -1;
 	}
@@ -5290,7 +5295,7 @@
 	if (a->argc != 3)
 		return CLI_SHOWUSAGE;
 	ast_cli(a->fd, FORMAT2, "Channel", "Peer", "Username", "ID (Lo/Rem)", "Seq (Tx/Rx)", "Lag", "Jitter", "JitBuf", "Format");
-	for (x = 0; x < IAX_MAX_CALLS; x++) {
+	for (x = 0; x < ARRAY_LEN(iaxs); x++) {
 		ast_mutex_lock(&iaxsl[x]);
 		if (iaxs[x]) {
 			int lag, jitter, localdelay;
@@ -5332,7 +5337,7 @@
 	int numchans = 0;
 #define ACN_FORMAT1 "%-25.25s %4d %4d %4d %5d %3d %5d %4d %6d %4d %4d %5d %3d %5d %4d %6d\n"
 #define ACN_FORMAT2 "%s %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n"
-	for (x=0;x<IAX_MAX_CALLS;x++) {
+	for (x = 0; x < ARRAY_LEN(iaxs); x++) {
 		ast_mutex_lock(&iaxsl[x]);
 		if (iaxs[x]) {
 			int localjitter, localdelay, locallost, locallosspct, localdropped, localooo;
@@ -11169,7 +11174,7 @@
 	struct parsed_dial_string pds;
 	char *tmpstr;
 
-	for (x=0; x<IAX_MAX_CALLS; x++) {
+	for (x = 0; x < ARRAY_LEN(iaxs); x++) {
 		/* Look for an *exact match* call.  Once a call is negotiated, it can only
 		   look up entries for a single context */
 		if (!ast_mutex_trylock(&iaxsl[x])) {
@@ -11854,9 +11859,10 @@
 	
 	ast_netsock_release(netsock);
 	ast_netsock_release(outsock);
-	for (x = 0; x < IAX_MAX_CALLS; x++) {
-		if (iaxs[x])
+	for (x = 0; x < ARRAY_LEN(iaxs); x++) {
+		if (iaxs[x]) {
 			iax2_destroy(x);
+		}
 	}
 	ast_manager_unregister( "IAXpeers" );
 	ast_manager_unregister( "IAXpeerlist" );
@@ -11870,8 +11876,9 @@
 	sched_context_destroy(sched);
 	reload_firmware(1);
 
-	for (x = 0; x < IAX_MAX_CALLS; x++)
+	for (x = 0; x < ARRAY_LEN(iaxsl); x++) {
 		ast_mutex_destroy(&iaxsl[x]);
+	}
 
 	ao2_ref(peers, -1);
 	ao2_ref(users, -1);
@@ -11960,8 +11967,9 @@
 
 	memset(iaxs, 0, sizeof(iaxs));
 
-	for (x=0;x<IAX_MAX_CALLS;x++)
+	for (x = 0; x < ARRAY_LEN(iaxsl); x++) {
 		ast_mutex_init(&iaxsl[x]);
+	}
 
 	ast_cond_init(&sched_cond, NULL);
 

Modified: team/russell/iax2_find_callno/channels/iax2.h
URL: http://svn.digium.com/view/asterisk/team/russell/iax2_find_callno/channels/iax2.h?view=diff&rev=114885&r1=114884&r2=114885
==============================================================================
--- team/russell/iax2_find_callno/channels/iax2.h (original)
+++ team/russell/iax2_find_callno/channels/iax2.h Wed Apr 30 09:50:47 2008
@@ -26,7 +26,12 @@
 /* Max version of IAX protocol we support */
 #define IAX_PROTO_VERSION 2
 
+/* NOTE: IT IS CRITICAL THAT IAX_MAX_CALLS BE A POWER OF 2. */
+#if defined(LOW_MEMORY)
+#define IAX_MAX_CALLS 2048
+#else
 #define IAX_MAX_CALLS 32768
+#endif
 
 #define IAX_FLAG_FULL		0x8000
 




More information about the asterisk-commits mailing list