[asterisk-commits] seanbright: branch 11 r380255 - in /branches/11: ./ channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 28 15:08:08 CST 2013


Author: seanbright
Date: Mon Jan 28 15:08:04 2013
New Revision: 380255

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=380255
Log:
Correct the number of available call numbers in IAX2.

There is currently an edge case where call number 32768 might be allocated for
a call, even though the IAX2 protocol requires call numbers be only 15 bits.
This resulted in some unpredictable behavior when call number 32678 is chosen.

This patch was mostly written by Richard Mudgett via ReviewBoard.  I'm just
committing it.

Review: https://reviewboard.asterisk.org/r/2293/
........

Merged revisions 380254 from http://svn.asterisk.org/svn/asterisk/branches/1.8

Modified:
    branches/11/   (props changed)
    branches/11/channels/chan_iax2.c
    branches/11/channels/iax2.h

Propchange: branches/11/
------------------------------------------------------------------------------
--- branch-1.8-merged (original)
+++ branch-1.8-merged Mon Jan 28 15:08:04 2013
@@ -1,1 +1,1 @@
-/branches/1.8:1-378147,378164,378356,378375,378427,378455-378456,378486,378514,378554,378591,378733,378776,378933,378967,379001,379145,379178,379226,379276,379310,379342,379392,379547,379608,379718,379825,379885,379963,380210
+/branches/1.8:1-378147,378164,378356,378375,378427,378455-378456,378486,378514,378554,378591,378733,378776,378933,378967,379001,379145,379178,379226,379276,379310,379342,379392,379547,379608,379718,379825,379885,379963,380210,380254

Modified: branches/11/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/channels/chan_iax2.c?view=diff&rev=380255&r1=380254&r2=380255
==============================================================================
--- branches/11/channels/chan_iax2.c (original)
+++ branches/11/channels/chan_iax2.c Mon Jan 28 15:08:04 2013
@@ -866,7 +866,7 @@
  *
  * \note Contents protected by the iaxsl[] locks
  */
-static AST_LIST_HEAD_NOLOCK(, iax_frame) frame_queue[IAX_MAX_CALLS + 1];
+static AST_LIST_HEAD_NOLOCK(, iax_frame) frame_queue[IAX_MAX_CALLS];
 
 static struct ast_taskprocessor *transmit_processor;
 
@@ -1068,7 +1068,7 @@
  * based on the local call number.  The local call number is used as the
  * index into the array where the associated pvt structure is stored.
  */
-static struct chan_iax2_pvt *iaxs[IAX_MAX_CALLS + 1];
+static struct chan_iax2_pvt *iaxs[IAX_MAX_CALLS];
 
 static struct ast_callid *iax_pvt_callid_get(int callno)
 {
@@ -1125,7 +1125,7 @@
 
 /* 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	IAX_MAX_CALLS / 2
+#define TRUNK_CALL_START	(IAX_MAX_CALLS / 2)
 
 /* Debug routines... */
 static struct sockaddr_in debugaddr;
@@ -2144,7 +2144,7 @@
 		ast_log(LOG_WARNING, "Can't make trunk once a call has started!\n");
 		return -1;
 	}
-	if (callno & TRUNK_CALL_START) {
+	if (callno >= TRUNK_CALL_START) {
 		ast_log(LOG_WARNING, "Call %d is already a trunk\n", callno);
 		return -1;
 	}
@@ -2782,7 +2782,7 @@
 	}
 
 	/* start at 2, 0 and 1 are reserved */
-	for (i = 2; i <= IAX_MAX_CALLS; i++) {
+	for (i = 2; i < IAX_MAX_CALLS; i++) {
 		struct callno_entry *callno_entry;
 
 		if (!(callno_entry = ao2_alloc(sizeof(*callno_entry), NULL))) {

Modified: branches/11/channels/iax2.h
URL: http://svnview.digium.com/svn/asterisk/branches/11/channels/iax2.h?view=diff&rev=380255&r1=380254&r2=380255
==============================================================================
--- branches/11/channels/iax2.h (original)
+++ branches/11/channels/iax2.h Mon Jan 28 15:08:04 2013
@@ -26,9 +26,13 @@
 /* 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. */
+/* NOTE: It is recommended that IAX_MAX_CALLS be a power of 2, but it is not
+ * required.  The maximum number of calls supported by the protocol is 32768.
+ *
+ * For LOW_MEMORY, we use 2049 for compatibility with earlier code because
+ * callno 2048 leaked out when the intended callno range was 2 - 2047. */
 #if defined(LOW_MEMORY)
-#define IAX_MAX_CALLS 2048
+#define IAX_MAX_CALLS 2049
 #else
 #define IAX_MAX_CALLS 32768
 #endif




More information about the asterisk-commits mailing list