[asterisk-commits] crichter: branch crichter/0.4.0 r39313 - in /team/crichter/0.4.0: ./ apps/ ch...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Aug 8 05:16:11 MST 2006


Author: crichter
Date: Tue Aug  8 07:16:10 2006
New Revision: 39313

URL: http://svn.digium.com/view/asterisk?rev=39313&view=rev
Log:
Merged revisions 39311 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/team/crichter/0.3.0

................
r39311 | crichter | 2006-08-08 14:02:59 +0200 (Di, 08 Aug 2006) | 65 lines

Merged revisions 38903-38904,38928,38950,38972,38982,39056,39081 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r38903 | russell | 2006-08-05 07:07:39 +0200 (Sa, 05 Aug 2006) | 2 lines

suppress a compiler warning about the usage of a potentially uninitialized variable

........
r38904 | russell | 2006-08-05 07:08:50 +0200 (Sa, 05 Aug 2006) | 10 lines

Fix an issue that would cause a NewCallerID manager event to be generated
before the channel's NewChannel event.  This was due to a somewhat recent
change that included using ast_set_callerid() where it wasn't before.  This
function should not be used in the channel driver "new" functions.
(issue #7654, fixed by me)

Also, fix a couple minor bugs in usecount handling.  chan_iax2 could have
increased the usecount but then returned an error.  The place where chan_sip
increased the usecount did not call ast_update_usecount()

........
r38928 | russell | 2006-08-05 08:37:59 +0200 (Sa, 05 Aug 2006) | 3 lines

make sure the priv-callerintros directory exists before trying to create a file
there (issue #7659, patch by hads, with some modifications by me)

........
r38950 | russell | 2006-08-05 09:21:12 +0200 (Sa, 05 Aug 2006) | 3 lines

don't advertise that this function can set a SIP header when it can only
do reads

........
r38972 | russell | 2006-08-05 10:08:48 +0200 (Sa, 05 Aug 2006) | 3 lines

remove duplicate queue log entry when the caller exits on a timeout
(issue #7616, ppyy)

........
r38982 | russell | 2006-08-05 11:01:37 +0200 (Sa, 05 Aug 2006) | 6 lines

Always generate a Newstate event in ast_setstate() instead of making it a
Newchannel event if the state was AST_STATE_DOWN.  The Newchannel event will
always be generated in ast_request(), so this just causes a duplicated
Newchannel event in some cases.  
(issue #7506, repoted by capouch, fixed by me)

........
r39056 | file | 2006-08-07 02:15:51 +0200 (Mo, 07 Aug 2006) | 2 lines

Reset our stream and vstream pointers back to NULL so that any generator that uses them (file based MOH) will not try to close them again. (issue #7668 reported by jmls)

........
r39081 | russell | 2006-08-07 03:28:29 +0200 (Mo, 07 Aug 2006) | 7 lines

Fix a crash reported to me by hads on IRC.  This crash would occur with the use
of the "distinctiveringaftercid" option.  Also, on this user's system, the crash
would only occur when built without optimizations.  This is because the bug is
that the code would write past the end of an array that was allocated on the
stack, and the structure of the stack is different with or without optimizations
enabled.

........

................

Modified:
    team/crichter/0.4.0/   (props changed)
    team/crichter/0.4.0/apps/app_dial.c
    team/crichter/0.4.0/apps/app_queue.c
    team/crichter/0.4.0/channel.c
    team/crichter/0.4.0/channels/chan_h323.c
    team/crichter/0.4.0/channels/chan_iax2.c
    team/crichter/0.4.0/channels/chan_mgcp.c
    team/crichter/0.4.0/channels/chan_misdn.c
    team/crichter/0.4.0/channels/chan_modem.c
    team/crichter/0.4.0/channels/chan_phone.c
    team/crichter/0.4.0/channels/chan_sip.c
    team/crichter/0.4.0/channels/chan_skinny.c
    team/crichter/0.4.0/channels/chan_vpb.c
    team/crichter/0.4.0/channels/chan_zap.c

Propchange: team/crichter/0.4.0/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/crichter/0.4.0/
------------------------------------------------------------------------------
--- automerge-email (original)
+++ automerge-email Tue Aug  8 07:16:10 2006
@@ -1,1 +1,1 @@
-christian.richter at beronet.com
+cr at beronet.com

Propchange: team/crichter/0.4.0/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Aug  8 07:16:10 2006
@@ -1,1 +1,1 @@
-/team/crichter/0.3.0:1-39295
+/team/crichter/0.3.0:1-39312

Modified: team/crichter/0.4.0/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/apps/app_dial.c?rev=39313&r1=39312&r2=39313&view=diff
==============================================================================
--- team/crichter/0.4.0/apps/app_dial.c (original)
+++ team/crichter/0.4.0/apps/app_dial.c Tue Aug  8 07:16:10 2006
@@ -31,6 +31,7 @@
 #include <stdio.h>
 #include <sys/time.h>
 #include <sys/signal.h>
+#include <sys/stat.h>
 #include <netinet/in.h>
 
 #include "asterisk.h"
@@ -965,7 +966,13 @@
 			   unless it is already there-- this should be done before the 
 			   call is actually dialed  */
 
-			/* make sure the priv-callerintros dir exists? */
+			/* make sure the priv-callerintros dir actually exists */
+			snprintf(privintro, sizeof(privintro), "%s/sounds/priv-callerintros", ast_config_AST_VAR_DIR);
+			if (mkdir(privintro, 0755) && errno != EEXIST) {
+				ast_log(LOG_WARNING, "privacy: can't create directory priv-callerintros: %s\n", strerror(errno));
+				res = -1;
+				goto out;
+			}
 
 			snprintf(privintro,sizeof(privintro),"priv-callerintros/%s", privcid);
 			if( ast_fileexists(privintro,NULL,NULL ) > 0 && strncmp(privcid,"NOCALLERID",10) != 0) {

Modified: team/crichter/0.4.0/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/apps/app_queue.c?rev=39313&r1=39312&r2=39313&view=diff
==============================================================================
--- team/crichter/0.4.0/apps/app_queue.c (original)
+++ team/crichter/0.4.0/apps/app_queue.c Tue Aug  8 07:16:10 2006
@@ -2018,7 +2018,6 @@
 		/* If we have timed out, break out */
 		if (qe->expire && (time(NULL) > qe->expire)) {
 			*reason = QUEUE_TIMEOUT;
-			ast_queue_log(qe->parent->name, qe->chan->uniqueid,"NONE", "EXITWITHTIMEOUT", "%d", qe->pos);
 			break;
 		}
 

Modified: team/crichter/0.4.0/channel.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channel.c?rev=39313&r1=39312&r2=39313&view=diff
==============================================================================
--- team/crichter/0.4.0/channel.c (original)
+++ team/crichter/0.4.0/channel.c Tue Aug  8 07:16:10 2006
@@ -1307,10 +1307,16 @@
 		return 0;
 	}
 	free_translation(chan);
-	if (chan->stream) 		/* Close audio stream */
+	/* Close audio stream */
+	if (chan->stream) {
 		ast_closestream(chan->stream);
-	if (chan->vstream)		/* Close video stream */
+		chan->stream = NULL;
+	}
+	/* Close video stream */
+	if (chan->vstream) {
 		ast_closestream(chan->vstream);
+		chan->vstream = NULL;
+	}
 	if (chan->sched) {
 		sched_context_destroy(chan->sched);
 		chan->sched = NULL;
@@ -3190,8 +3196,7 @@
 
 	chan->_state = state;
 	ast_device_state_changed_literal(chan->name);
-	manager_event(EVENT_FLAG_CALL,
-		      (oldstate == AST_STATE_DOWN) ? "Newchannel" : "Newstate",
+	manager_event(EVENT_FLAG_CALL, "Newstate",
 		      "Channel: %s\r\n"
 		      "State: %s\r\n"
 		      "CallerID: %s\r\n"
@@ -3440,7 +3445,7 @@
 	}
 
 	for (/* ever */;;) {
-		struct timeval now;
+		struct timeval now = { 0, };
 		int to;
 
 		to = -1;

Modified: team/crichter/0.4.0/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_h323.c?rev=39313&r1=39312&r2=39313&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_h323.c (original)
+++ team/crichter/0.4.0/channels/chan_h323.c Tue Aug  8 07:16:10 2006
@@ -770,15 +770,15 @@
 			ch->amaflags = pvt->amaflags;
 		}
 
-		/*
-		 * If cid_num and cdi.call_source_e164 are both null, then
-		 * ast_set_callerid will do the right thing and leave the
-		 * cid_num and cid_ani for the channel alone.
-		 */
-		ast_set_callerid(ch,
-			!ast_strlen_zero(pvt->cid_num) ? pvt->cid_num : pvt->cd.call_source_e164,
-			pvt->cid_name,
-			!ast_strlen_zero(pvt->cid_num) ? pvt->cid_num : pvt->cd.call_source_e164);
+		if (!ast_strlen_zero(pvt->cid_num)) {
+			ch->cid.cid_num = strdup(pvt->cid_num);
+			ch->cid.cid_ani = strdup(pvt->cid_num);
+		} else if (!ast_strlen_zero(pvt->cd.call_source_e164)) {
+			ch->cid.cid_num = strdup(pvt->cd.call_source_e164);
+			ch->cid.cid_ani = strdup(pvt->cd.call_source_e164);
+		}
+		if (!ast_strlen_zero(pvt->cid_name))
+			ch->cid.cid_name = strdup(pvt->cid_name);
 
 		if (!ast_strlen_zero(pvt->rdnis)) {
 			ch->cid.cid_rdnis = strdup(pvt->rdnis);

Modified: team/crichter/0.4.0/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_iax2.c?rev=39313&r1=39312&r2=39313&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_iax2.c (original)
+++ team/crichter/0.4.0/channels/chan_iax2.c Tue Aug  8 07:16:10 2006
@@ -3442,15 +3442,22 @@
 		tmp->writeformat = ast_best_codec(capability);
 		tmp->tech_pvt = CALLNO_TO_PTR(i->callno);
 
-		ast_set_callerid(tmp, i->cid_num, i->cid_name,
-			i->ani ? i->ani : i->cid_num);
+		if (!ast_strlen_zero(i->cid_num))
+			tmp->cid.cid_num = strdup(i->cid_num);
+		if (!ast_strlen_zero(i->cid_name))
+			tmp->cid.cid_name = strdup(i->cid_name);
+		if (!ast_strlen_zero(i->ani))
+			tmp->cid.cid_ani = strdup(i->ani);
+		else if (!ast_strlen_zero(i->cid_num))
+			tmp->cid.cid_ani = strdup(i->cid_num);
+		tmp->cid.cid_pres = i->calling_pres;
+		tmp->cid.cid_ton = i->calling_ton;
+		tmp->cid.cid_tns = i->calling_tns;
+
 		if (!ast_strlen_zero(i->language))
 			ast_copy_string(tmp->language, i->language, sizeof(tmp->language));
 		if (!ast_strlen_zero(i->dnid))
 			tmp->cid.cid_dnid = strdup(i->dnid);
-		tmp->cid.cid_pres = i->calling_pres;
-		tmp->cid.cid_ton = i->calling_ton;
-		tmp->cid.cid_tns = i->calling_tns;
 		if (!ast_strlen_zero(i->accountcode))
 			ast_copy_string(tmp->accountcode, i->accountcode, sizeof(tmp->accountcode));
 		if (i->amaflags)
@@ -3461,10 +3468,6 @@
 		i->owner = tmp;
 		i->capability = capability;
 		ast_setstate(tmp, state);
-		ast_mutex_lock(&usecnt_lock);
-		usecnt++;
-		ast_mutex_unlock(&usecnt_lock);
-		ast_update_use_count();
 		if (state != AST_STATE_DOWN) {
 			if (ast_pbx_start(tmp)) {
 				ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
@@ -3475,6 +3478,10 @@
 		for (v = i->vars ; v ; v = v->next)
 			pbx_builtin_setvar_helper(tmp,v->name,v->value);
 		
+		ast_mutex_lock(&usecnt_lock);
+		usecnt++;
+		ast_mutex_unlock(&usecnt_lock);
+		ast_update_use_count();
 	}
 	return tmp;
 }

Modified: team/crichter/0.4.0/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_mgcp.c?rev=39313&r1=39312&r2=39313&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_mgcp.c (original)
+++ team/crichter/0.4.0/channels/chan_mgcp.c Tue Aug  8 07:16:10 2006
@@ -1428,7 +1428,14 @@
 		strncpy(tmp->call_forward, i->call_forward, sizeof(tmp->call_forward) - 1);
 		strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
 		strncpy(tmp->exten, i->exten, sizeof(tmp->exten)-1);
-		ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
+
+		if (!ast_strlen_zero(i->cid_num)) {
+			tmp->cid.cid_num = strdup(i->cid_num);
+			tmp->cid.cid_ani = strdup(i->cid_num);
+		}
+		if (!ast_strlen_zero(i->cid_name))
+			tmp->cid.cid_name = strdup(i->cid_name);
+		
 		if (!i->adsi)
 			tmp->adsicpe = AST_ADSI_UNAVAILABLE;
 		tmp->priority = 1;

Modified: team/crichter/0.4.0/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_misdn.c?rev=39313&r1=39312&r2=39313&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_misdn.c (original)
+++ team/crichter/0.4.0/channels/chan_misdn.c Tue Aug  8 07:16:10 2006
@@ -3087,9 +3087,13 @@
 			char *cid_name, *cid_num;
       
 			ast_callerid_parse(callerid, &cid_name, &cid_num);
-			ast_set_callerid(tmp, cid_num,cid_name,cid_num);
-		} else {
-			ast_set_callerid(tmp, NULL,NULL,NULL);
+
+			if (!ast_strlen_zero(cid_num)) {
+				tmp->cid.cid_num = strdup(cid_num);
+				tmp->cid.cid_ani = strdup(cid_num);
+			}
+			if (!ast_strlen_zero(cid_name))
+				tmp->cid.cid_name = strdup(cid_name);
 		}
 
 		{

Modified: team/crichter/0.4.0/channels/chan_modem.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_modem.c?rev=39313&r1=39312&r2=39313&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_modem.c (original)
+++ team/crichter/0.4.0/channels/chan_modem.c Tue Aug  8 07:16:10 2006
@@ -573,7 +573,12 @@
 		tmp->tech_pvt = i;
 		strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
 
-		ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
+		if (!ast_strlen_zero(i->cid_num)) {
+			tmp->cid.cid_num = strdup(i->cid_num);
+			tmp->cid.cid_ani = strdup(i->cid_num);
+		}
+		if (!ast_strlen_zero(i->cid_name))
+			tmp->cid.cid_name = strdup(i->cid_name);
 
 		if (!ast_strlen_zero(i->language))
 			strncpy(tmp->language,i->language, sizeof(tmp->language)-1);

Modified: team/crichter/0.4.0/channels/chan_phone.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_phone.c?rev=39313&r1=39312&r2=39313&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_phone.c (original)
+++ team/crichter/0.4.0/channels/chan_phone.c Tue Aug  8 07:16:10 2006
@@ -825,7 +825,14 @@
 			strncpy(tmp->exten, "s",  sizeof(tmp->exten) - 1);
 		if (!ast_strlen_zero(i->language))
 			strncpy(tmp->language, i->language, sizeof(tmp->language)-1);
-		ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
+
+		if (!ast_strlen_zero(i->cid_num)) {
+			tmp->cid.cid_num = strdup(i->cid_num);
+			tmp->cid.cid_ani = strdup(i->cid_num);
+		}
+		if (!ast_strlen_zero(i->cid_name))
+			tmp->cid.cid_name = strdup(i->cid_name);
+
 		i->owner = tmp;
 		ast_mutex_lock(&usecnt_lock);
 		usecnt++;

Modified: team/crichter/0.4.0/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_sip.c?rev=39313&r1=39312&r2=39313&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_sip.c (original)
+++ team/crichter/0.4.0/channels/chan_sip.c Tue Aug  8 07:16:10 2006
@@ -2821,16 +2821,20 @@
 	if (!ast_strlen_zero(i->musicclass))
 		ast_copy_string(tmp->musicclass, i->musicclass, sizeof(tmp->musicclass));
 	i->owner = tmp;
-	ast_mutex_lock(&usecnt_lock);
-	usecnt++;
-	ast_mutex_unlock(&usecnt_lock);
 	ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
 	ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
-	ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
+
+	if (!ast_strlen_zero(i->cid_num)) {
+		tmp->cid.cid_num = strdup(i->cid_num);
+		tmp->cid.cid_ani = strdup(i->cid_num);
+	}
+	if (!ast_strlen_zero(i->cid_name))
+		tmp->cid.cid_name = strdup(i->cid_name);
 	if (!ast_strlen_zero(i->rdnis))
 		tmp->cid.cid_rdnis = strdup(i->rdnis);
 	if (!ast_strlen_zero(i->exten) && strcmp(i->exten, "s"))
 		tmp->cid.cid_dnid = strdup(i->exten);
+
 	tmp->priority = 1;
 	if (!ast_strlen_zero(i->uri)) {
 		pbx_builtin_setvar_helper(tmp, "SIPURI", i->uri);
@@ -2860,6 +2864,11 @@
 	for (v = i->chanvars ; v ; v = v->next)
 		pbx_builtin_setvar_helper(tmp,v->name,v->value);
 				
+	ast_mutex_lock(&usecnt_lock);
+	usecnt++;
+	ast_mutex_unlock(&usecnt_lock);
+	ast_update_use_count();	
+	
 	return tmp;
 }
 
@@ -9322,7 +9331,7 @@
 
 static struct ast_custom_function sip_header_function = {
 	.name = "SIP_HEADER",
-	.synopsis = "Gets or sets the specified SIP header",
+	.synopsis = "Gets the specified SIP header",
 	.syntax = "SIP_HEADER(<name>)",
 	.read = func_header_read,
 };

Modified: team/crichter/0.4.0/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_skinny.c?rev=39313&r1=39312&r2=39313&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_skinny.c (original)
+++ team/crichter/0.4.0/channels/chan_skinny.c Tue Aug  8 07:16:10 2006
@@ -2279,7 +2279,14 @@
 		strncpy(tmp->call_forward, l->call_forward, sizeof(tmp->call_forward) - 1);
 		strncpy(tmp->context, l->context, sizeof(tmp->context)-1);
 		strncpy(tmp->exten,l->exten, sizeof(tmp->exten)-1);
-		ast_set_callerid(tmp, l->cid_num, l->cid_name, l->cid_num);
+
+		if (!ast_strlen_zero(l->cid_num)) {
+			tmp->cid.cid_num = strdup(l->cid_num);
+			tmp->cid.cid_ani = strdup(l->cid_num);
+		}
+		if (!ast_strlen_zero(l->cid_name))
+			tmp->cid.cid_name = strdup(l->cid_name);
+
 		tmp->priority = 1;
 		tmp->adsicpe = AST_ADSI_UNAVAILABLE;
 

Modified: team/crichter/0.4.0/channels/chan_vpb.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_vpb.c?rev=39313&r1=39312&r2=39313&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_vpb.c (original)
+++ team/crichter/0.4.0/channels/chan_vpb.c Tue Aug  8 07:16:10 2006
@@ -2647,7 +2647,12 @@
 			cid_name[0] = '\0';
 			cid_num[0] = '\0';
 			ast_callerid_split(me->callerid, cid_name, sizeof(cid_name), cid_num, sizeof(cid_num));
-			ast_set_callerid(tmp, cid_num, cid_name, cid_num);
+			if (!ast_strlen_zero(cid_num)) {
+				tmp->cid.cid_num = strdup(cid_num);
+				tmp->cid.cid_ani = strdup(cid_num);
+			}
+			if (!ast_strlen_zero(cid_name))
+				tmp->cid.cid_name = strdup(cid_name);
 		}
 		tmp->tech_pvt = me;
 		

Modified: team/crichter/0.4.0/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_zap.c?rev=39313&r1=39312&r2=39313&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_zap.c (original)
+++ team/crichter/0.4.0/channels/chan_zap.c Tue Aug  8 07:16:10 2006
@@ -765,8 +765,6 @@
 	{ { 125, 125, 125, 125, 125, 4000 } },	/*!< Three short bursts */
 	{ { 1000, 500, 2500, 5000 } },	/*!< Long ring */
 };
-
-int receivedRingT; /*!< Used to find out what ringtone we are on */
 
 /*! \brief cidrings says in which pause to transmit the cid information, where the first pause
  * is 1, the second pause is 2 and so on.
@@ -5178,9 +5176,21 @@
 			tmp->cid.cid_dnid = strdup(i->dnid);
 
 #ifdef PRI_ANI
-		ast_set_callerid(tmp, i->cid_num, i->cid_name, ast_strlen_zero(i->cid_ani) ? i->cid_num : i->cid_ani);
+		if (!ast_strlen_zero(i->cid_num))
+			tmp->cid.cid_num = strdup(i->cid_num);
+		if (!ast_strlen_zero(i->cid_name))
+			tmp->cid.cid_name = strdup(i->cid_name);
+		if (!ast_strlen_zero(i->cid_ani))
+			tmp->cid.cid_ani = strdup(i->cid_num);
+		else if (!ast_strlen_zero(i->cid_num))	
+			tmp->cid.cid_ani = strdup(i->cid_num);
 #else
-		ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
+		if (!ast_strlen_zero(i->cid_num)) {
+			tmp->cid.cid_num = strdup(i->cid_num);
+			tmp->cid.cid_ani = strdup(i->cid_num);
+		}
+		if (!ast_strlen_zero(i->cid_name))
+			tmp->cid.cid_name = strdup(i->cid_name);
 #endif
 		tmp->cid.cid_pres = i->callingpres;
 		tmp->cid.cid_ton = i->cid_ton;
@@ -5994,9 +6004,8 @@
 						len = 0;
 						distMatches = 0;
 						/* Clear the current ring data array so we dont have old data in it. */
-						for (receivedRingT=0; receivedRingT < 3; receivedRingT++) {
+						for (receivedRingT=0; receivedRingT < (sizeof(curRingData) / sizeof(curRingData[0])); receivedRingT++)
 							curRingData[receivedRingT] = 0;
-						}
 						receivedRingT = 0;
 						counter = 0;
 						counter1 = 0;
@@ -6024,8 +6033,10 @@
 		
 								if (p->ringt < p->ringt_base/2)
 									break;
-								++receivedRingT; /* Increment the ringT counter so we can match it against
-										values in zapata.conf for distinctive ring */
+								/* Increment the ringT counter so we can match it against
+								   values in zapata.conf for distinctive ring */
+								if (++receivedRingT == (sizeof(curRingData) / sizeof(curRingData[0])))
+									break;
 							} else if (i & ZT_IOMUX_READ) {
 								res = read(p->subs[index].zfd, buf, sizeof(buf));
 								if (res < 0) {
@@ -6096,9 +6107,8 @@
 				len = 0;
 				distMatches = 0;
 				/* Clear the current ring data array so we dont have old data in it. */
-				for (receivedRingT=0; receivedRingT < 3; receivedRingT++) {
+				for (receivedRingT=0; receivedRingT < (sizeof(curRingData) / sizeof(curRingData[0])); receivedRingT++)
 					curRingData[receivedRingT] = 0;
-				}
 				receivedRingT = 0;
 				counter = 0;
 				counter1 = 0;
@@ -6128,8 +6138,10 @@
 
 						if (p->ringt < p->ringt_base/2)
 							break;
-						++receivedRingT; /* Increment the ringT counter so we can match it against
-								values in zapata.conf for distinctive ring */
+						/* Increment the ringT counter so we can match it against
+						   values in zapata.conf for distinctive ring */
+						if (++receivedRingT == (sizeof(curRingData) / sizeof(curRingData[0])))
+							break;
 					} else if (i & ZT_IOMUX_READ) {
 						res = read(p->subs[index].zfd, buf, sizeof(buf));
 						if (res < 0) {



More information about the asterisk-commits mailing list