[svn-commits] russell: trunk r38905 - in /trunk: ./ channels/

svn-commits at lists.digium.com svn-commits at lists.digium.com
Fri Aug 4 22:26:29 MST 2006


Author: russell
Date: Sat Aug  5 00:26:29 2006
New Revision: 38905

URL: http://svn.digium.com/view/asterisk?rev=38905&view=rev
Log:
Merged revisions 38903-38904 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r38903 | russell | 2006-08-05 01:07:39 -0400 (Sat, 05 Aug 2006) | 2 lines

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

........
r38904 | russell | 2006-08-05 01:08:50 -0400 (Sat, 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()

........

Modified:
    trunk/   (props changed)
    trunk/channel.c
    trunk/channels/chan_h323.c
    trunk/channels/chan_iax2.c
    trunk/channels/chan_mgcp.c
    trunk/channels/chan_misdn.c
    trunk/channels/chan_phone.c
    trunk/channels/chan_sip.c
    trunk/channels/chan_skinny.c
    trunk/channels/chan_zap.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Modified: trunk/channel.c
URL: http://svn.digium.com/view/asterisk/trunk/channel.c?rev=38905&r1=38904&r2=38905&view=diff
==============================================================================
--- trunk/channel.c (original)
+++ trunk/channel.c Sat Aug  5 00:26:29 2006
@@ -3625,7 +3625,7 @@
 	}
 
 	for (/* ever */;;) {
-		struct timeval now;
+		struct timeval now = { 0, };
 		int to;
 
 		to = -1;

Modified: trunk/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_h323.c?rev=38905&r1=38904&r2=38905&view=diff
==============================================================================
--- trunk/channels/chan_h323.c (original)
+++ trunk/channels/chan_h323.c Sat Aug  5 00:26:29 2006
@@ -796,18 +796,19 @@
 		if (pvt->amaflags) {
 			ch->amaflags = pvt->amaflags;
 		}
-		/*
-		 * If cid_num and cd.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,
-			!ast_strlen_zero(pvt->cid_name) ? pvt->cid_name : pvt->cd.call_source_name,
-			!ast_strlen_zero(pvt->cid_num) ? pvt->cid_num : pvt->cd.call_source_e164);
-		if (!ast_strlen_zero(pvt->rdnis)) {
-			ch->cid.cid_rdnis = strdup(pvt->rdnis);
-		}
+		
+		/* Don't use ast_set_callerid() here because it will
+		 * generate a NewCallerID event before the NewChannel event */
+		if (!ast_strlen_zero(pvt->cid_num)) {
+			ch->cid.cid_num = ast_strdup(pvt->cid_num);
+			ch->cid.cid_ani = ast_strdup(pvt->cid_num);
+		} else {
+			ch->cid.cid_num = ast_strdup(pvt->cd.call_source_e164);
+			ch->cid.cid_ani = ast_strdup(pvt->cd.call_source_e164);
+		}
+		ch->cid.cid_name = ast_strdup(pvt->cid_name);
+		ch->cid.cid_rdnis = ast_strdup(pvt->rdnis);
+		
 		if (!ast_strlen_zero(pvt->exten) && strcmp(pvt->exten, "s")) {
 			ch->cid.cid_dnid = strdup(pvt->exten);
 		}

Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?rev=38905&r1=38904&r2=38905&view=diff
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Sat Aug  5 00:26:29 2006
@@ -3259,16 +3259,21 @@
 	tmp->writeformat = ast_best_codec(capability);
 	tmp->tech_pvt = CALLNO_TO_PTR(i->callno);
 
-	ast_set_callerid(tmp, i->cid_num, i->cid_name, S_OR(i->ani, i->cid_num));
-	if (!ast_strlen_zero(i->language))
-		ast_string_field_set(tmp, language, i->language);
-	if (!ast_strlen_zero(i->dnid))
-		tmp->cid.cid_dnid = ast_strdup(i->dnid);
-	if (!ast_strlen_zero(i->rdnis))
-		tmp->cid.cid_rdnis = ast_strdup(i->rdnis);
+	/* Don't use ast_set_callerid() here because it will
+	 * generate a NewCallerID event before the NewChannel event */
+	tmp->cid.cid_num = ast_strdup(i->cid_num);
+	tmp->cid.cid_name = ast_strdup(i->cid_name);
+	if (!ast_strlen_zero(i->ani))
+		tmp->cid.cid_ani = ast_strdup(i->ani);
+	else
+		tmp->cid.cid_ani = ast_strdup(i->cid_num);
+	tmp->cid.cid_dnid = ast_strdup(i->dnid);
+	tmp->cid.cid_rdnis = ast_strdup(i->rdnis);
 	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_string_field_set(tmp, language, i->language);
 	if (!ast_strlen_zero(i->accountcode))
 		ast_string_field_set(tmp, accountcode, i->accountcode);
 	if (i->amaflags)

Modified: trunk/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_mgcp.c?rev=38905&r1=38904&r2=38905&view=diff
==============================================================================
--- trunk/channels/chan_mgcp.c (original)
+++ trunk/channels/chan_mgcp.c Sat Aug  5 00:26:29 2006
@@ -1415,7 +1415,13 @@
 		ast_string_field_set(tmp, call_forward, i->call_forward);
 		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);
+
+		/* Don't use ast_set_callerid() here because it will
+		 * generate a NewCallerID event before the NewChannel event */
+		tmp->cid.cid_num = ast_strdup(i->cid_num);
+		tmp->cid.cid_ani = ast_strdup(i->cid_num);
+		tmp->cid.cid_name = ast_strdup(i->cid_name);
+		
 		if (!i->adsi)
 			tmp->adsicpe = AST_ADSI_UNAVAILABLE;
 		tmp->priority = 1;

Modified: trunk/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_misdn.c?rev=38905&r1=38904&r2=38905&view=diff
==============================================================================
--- trunk/channels/chan_misdn.c (original)
+++ trunk/channels/chan_misdn.c Sat Aug  5 00:26:29 2006
@@ -3099,9 +3099,11 @@
 			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);
+			/* Don't use ast_set_callerid() here because it will
+			 * generate a NewCallerID event before the NewChannel event */
+			tmp->cid.cid_num = ast_strdup(cid_num);
+			tmp->cid.cid_ani = ast_strdup(cid_num);
+			tmp->cid.cid_name = ast_strdup(cid_name);
 		}
 
 		{

Modified: trunk/channels/chan_phone.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_phone.c?rev=38905&r1=38904&r2=38905&view=diff
==============================================================================
--- trunk/channels/chan_phone.c (original)
+++ trunk/channels/chan_phone.c Sat Aug  5 00:26:29 2006
@@ -864,7 +864,13 @@
 			strncpy(tmp->exten, "s",  sizeof(tmp->exten) - 1);
 		if (!ast_strlen_zero(i->language))
 			ast_string_field_set(tmp, language, i->language);
-		ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
+
+		/* Don't use ast_set_callerid() here because it will
+		 * generate a NewCallerID event before the NewChannel event */
+		tmp->cid.cid_num = ast_strdup(i->cid_num);
+		tmp->cid.cid_ani = ast_strdup(i->cid_num);
+		tmp->cid.cid_name = ast_strdup(i->cid_name);
+
 		i->owner = tmp;
 		ast_mutex_lock(&usecnt_lock);
 		usecnt++;

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=38905&r1=38904&r2=38905&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Sat Aug  5 00:26:29 2006
@@ -3682,11 +3682,17 @@
 	ast_update_use_count();
 	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->rdnis))
-		tmp->cid.cid_rdnis = ast_strdup(i->rdnis);
+
+	/* Don't use ast_set_callerid() here because it will
+	 * generate a NewCallerID event before the NewChannel event */
+	tmp->cid.cid_num = ast_strdup(i->cid_num);
+	tmp->cid.cid_ani = ast_strdup(i->cid_num);
+	tmp->cid.cid_name = ast_strdup(i->cid_name);
+	tmp->cid.cid_rdnis = ast_strdup(i->rdnis);
+	
 	if (!ast_strlen_zero(i->exten) && strcmp(i->exten, "s"))
 		tmp->cid.cid_dnid = ast_strdup(i->exten);
+
 	tmp->priority = 1;
 	if (!ast_strlen_zero(i->uri))
 		pbx_builtin_setvar_helper(tmp, "SIPURI", i->uri);

Modified: trunk/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_skinny.c?rev=38905&r1=38904&r2=38905&view=diff
==============================================================================
--- trunk/channels/chan_skinny.c (original)
+++ trunk/channels/chan_skinny.c Sat Aug  5 00:26:29 2006
@@ -2582,7 +2582,13 @@
 		ast_string_field_set(tmp, call_forward, l->call_forward);
 		ast_copy_string(tmp->context, l->context, sizeof(tmp->context));
 		ast_copy_string(tmp->exten, l->exten, sizeof(tmp->exten));
-		ast_set_callerid(tmp, l->cid_num, l->cid_name, l->cid_num);
+
+		/* Don't use ast_set_callerid() here because it will
+		 * generate a NewCallerID event before the NewChannel event */
+		tmp->cid.cid_num = ast_strdup(l->cid_num);
+		tmp->cid.cid_ani = ast_strdup(l->cid_num);
+		tmp->cid.cid_name = ast_strdup(l->cid_name);
+
 		tmp->priority = 1;
 		tmp->adsicpe = AST_ADSI_UNAVAILABLE;
 

Modified: trunk/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_zap.c?rev=38905&r1=38904&r2=38905&view=diff
==============================================================================
--- trunk/channels/chan_zap.c (original)
+++ trunk/channels/chan_zap.c Sat Aug  5 00:26:29 2006
@@ -5217,9 +5217,18 @@
 		tmp->cid.cid_dnid = ast_strdup(i->dnid);
 
 #ifdef PRI_ANI
-	ast_set_callerid(tmp, i->cid_num, i->cid_name, S_OR(i->cid_ani, i->cid_num));
+	/* Don't use ast_set_callerid() here because it will
+	 * generate a NewCallerID event before the NewChannel event */
+	tmp->cid.cid_num = ast_strdup(i->cid_num);
+	tmp->cid.cid_name = ast_strdup(i->cid_name);
+	if (!ast_strlen_zero(i->cid_ani))
+		tmp->cid.cid_ani = ast_strdup(i->cid_num);
+	else	
+		tmp->cid.cid_ani = ast_strdup(i->cid_num);
 #else
-	ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
+	tmp->cid.cid_num = ast_strdup(i->cid_num);
+	tmp->cid.cid_ani = ast_strdup(i->cid_num);
+	tmp->cid.cid_name = ast_strdup(i->cid_name);
 #endif
 	tmp->cid.cid_pres = i->callingpres;
 	tmp->cid.cid_ton = i->cid_ton;



More information about the svn-commits mailing list