[asterisk-commits] branch crichter/0.3.0 r36799 - in /team/crichter/0.3.0: ./ channels/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Jul 3 00:55:01 MST 2006


Author: crichter
Date: Mon Jul  3 02:55:01 2006
New Revision: 36799

URL: http://svn.digium.com/view/asterisk?rev=36799&view=rev
Log:
Merged revisions 36725,36751 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r36725 | russell | 2006-07-03 06:19:09 +0200 (Mo, 03 Jul 2006) | 4 lines

use ast_set_callerid to be more consistent and to make sure that the
"callerid" option in the conf files is always handled the same way and sets ANI
(issue #7285, gkloepfer)

........
r36751 | russell | 2006-07-03 07:12:03 +0200 (Mo, 03 Jul 2006) | 3 lines

fix a race condition that caused asterisk to log a *ton* of warnings on mac
osx about poll returning an error because the polled file descriptor was bad.

........

Modified:
    team/crichter/0.3.0/   (props changed)
    team/crichter/0.3.0/asterisk.c
    team/crichter/0.3.0/channels/chan_agent.c
    team/crichter/0.3.0/channels/chan_features.c
    team/crichter/0.3.0/channels/chan_h323.c
    team/crichter/0.3.0/channels/chan_iax2.c
    team/crichter/0.3.0/channels/chan_local.c
    team/crichter/0.3.0/channels/chan_mgcp.c
    team/crichter/0.3.0/channels/chan_modem.c
    team/crichter/0.3.0/channels/chan_phone.c
    team/crichter/0.3.0/channels/chan_sip.c
    team/crichter/0.3.0/channels/chan_skinny.c

Propchange: team/crichter/0.3.0/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jul  3 02:55:01 2006
@@ -1,1 +1,1 @@
-/branches/1.2:1-36702
+/branches/1.2:1-36798

Modified: team/crichter/0.3.0/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/asterisk.c?rev=36799&r1=36798&r2=36799&view=diff
==============================================================================
--- team/crichter/0.3.0/asterisk.c (original)
+++ team/crichter/0.3.0/asterisk.c Mon Jul  3 02:55:01 2006
@@ -592,6 +592,7 @@
 		fds[0].fd = ast_socket;
 		fds[0].events= POLLIN;
 		s = poll(fds, 1, -1);
+		pthread_testcancel();
 		if (s < 0) {
 			if (errno != EINTR)
 				ast_log(LOG_WARNING, "poll returned error: %s\n", strerror(errno));
@@ -905,13 +906,13 @@
 		ast_log(LOG_DEBUG, "Asterisk ending (%d).\n", num);
 	manager_event(EVENT_FLAG_SYSTEM, "Shutdown", "Shutdown: %s\r\nRestart: %s\r\n", ast_active_channels() ? "Uncleanly" : "Cleanly", restart ? "True" : "False");
 	if (ast_socket > -1) {
+		pthread_cancel(lthread);
 		close(ast_socket);
 		ast_socket = -1;
+		unlink(ast_config_AST_SOCKET);
 	}
 	if (ast_consock > -1)
 		close(ast_consock);
-	if (ast_socket > -1)
-		unlink((char *)ast_config_AST_SOCKET);
 	if (!option_remote) unlink((char *)ast_config_AST_PID);
 	printf(term_quit());
 	if (restart) {

Modified: team/crichter/0.3.0/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/chan_agent.c?rev=36799&r1=36798&r2=36799&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/chan_agent.c (original)
+++ team/crichter/0.3.0/channels/chan_agent.c Mon Jul  3 02:55:01 2006
@@ -661,18 +661,8 @@
 		/* Call on this agent */
 		if (option_verbose > 2)
 			ast_verbose(VERBOSE_PREFIX_3 "outgoing agentcall, to agent '%s', on '%s'\n", p->agent, p->chan->name);
-		if (p->chan->cid.cid_num)
-			free(p->chan->cid.cid_num);
-		if (ast->cid.cid_num)
-			p->chan->cid.cid_num = strdup(ast->cid.cid_num);
-		else
-			p->chan->cid.cid_num = NULL;
-		if (p->chan->cid.cid_name)
-			free(p->chan->cid.cid_name);
-		if (ast->cid.cid_name)
-			p->chan->cid.cid_name = strdup(ast->cid.cid_name);
-		else
-			p->chan->cid.cid_name = NULL;
+		ast_set_callerid(p->chan,
+			ast->cid.cid_num, ast->cid.cid_name, NULL);
 		ast_channel_inherit_variables(ast, p->chan);
 		res = ast_call(p->chan, p->loginchan, 0);
 		CLEANUP(ast,p);

Modified: team/crichter/0.3.0/channels/chan_features.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/chan_features.c?rev=36799&r1=36798&r2=36799&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/chan_features.c (original)
+++ team/crichter/0.3.0/channels/chan_features.c Mon Jul  3 02:55:01 2006
@@ -328,25 +328,14 @@
 		ast_mutex_lock(&p->lock);
 		x = indexof(p, ast, 0);
 		if (!x && p->subchan) {
-			if (p->owner->cid.cid_num)
-				p->subchan->cid.cid_num = strdup(p->owner->cid.cid_num);
-			else 
-				p->subchan->cid.cid_num = NULL;
-		
-			if (p->owner->cid.cid_name)
-				p->subchan->cid.cid_name = strdup(p->owner->cid.cid_name);
-			else 
-				p->subchan->cid.cid_name = NULL;
+			ast_set_callerid(p->subchan,
+				p->owner->cid.cid_num, p->owner->cid.cid_name,
+				p->owner->cid.cid_ani ? p->owner->cid.cid_ani : p->owner->cid.cid_num);
 		
 			if (p->owner->cid.cid_rdnis)
 				p->subchan->cid.cid_rdnis = strdup(p->owner->cid.cid_rdnis);
 			else
 				p->subchan->cid.cid_rdnis = NULL;
-		
-			if (p->owner->cid.cid_ani)
-				p->subchan->cid.cid_ani = strdup(p->owner->cid.cid_ani);
-			else
-				p->subchan->cid.cid_ani = NULL;
 		
 			p->subchan->cid.cid_pres = p->owner->cid.cid_pres;
 			strncpy(p->subchan->language, p->owner->language, sizeof(p->subchan->language) - 1);

Modified: team/crichter/0.3.0/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/chan_h323.c?rev=36799&r1=36798&r2=36799&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/chan_h323.c (original)
+++ team/crichter/0.3.0/channels/chan_h323.c Mon Jul  3 02:55:01 2006
@@ -769,16 +769,17 @@
 		if (pvt->amaflags) {
 			ch->amaflags = pvt->amaflags;
 		}
-		if (!ast_strlen_zero(pvt->cid_num)) {
-			ch->cid.cid_num = strdup(pvt->cid_num);
-		} else if (!ast_strlen_zero(pvt->cd.call_source_e164)) {
-			ch->cid.cid_num = strdup(pvt->cd.call_source_e164);
-		}
-		if (!ast_strlen_zero(pvt->cid_name)) {
-			ch->cid.cid_name = strdup(pvt->cid_name);
-		} else if (!ast_strlen_zero(pvt->cd.call_source_name)) {
-			ch->cid.cid_name = strdup(pvt->cd.call_source_name);
-		}
+
+		/*
+		 * 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->rdnis)) {
 			ch->cid.cid_rdnis = strdup(pvt->rdnis);
 		}

Modified: team/crichter/0.3.0/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/chan_iax2.c?rev=36799&r1=36798&r2=36799&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/chan_iax2.c (original)
+++ team/crichter/0.3.0/channels/chan_iax2.c Mon Jul  3 02:55:01 2006
@@ -3412,12 +3412,8 @@
 		tmp->writeformat = ast_best_codec(capability);
 		tmp->tech_pvt = CALLNO_TO_PTR(i->callno);
 
-		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);
+		ast_set_callerid(tmp, i->cid_num, i->cid_name,
+			i->ani ? i->ani : i->cid_num);
 		if (!ast_strlen_zero(i->language))
 			ast_copy_string(tmp->language, i->language, sizeof(tmp->language));
 		if (!ast_strlen_zero(i->dnid))

Modified: team/crichter/0.3.0/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/chan_local.c?rev=36799&r1=36798&r2=36799&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/chan_local.c (original)
+++ team/crichter/0.3.0/channels/chan_local.c Mon Jul  3 02:55:01 2006
@@ -336,25 +336,15 @@
 	size_t len, namelen;
 	
 	ast_mutex_lock(&p->lock);
-	if (p->owner->cid.cid_num)
-		p->chan->cid.cid_num = strdup(p->owner->cid.cid_num);
-	else 
-		p->chan->cid.cid_num = NULL;
-
-	if (p->owner->cid.cid_name)
-		p->chan->cid.cid_name = strdup(p->owner->cid.cid_name);
-	else 
-		p->chan->cid.cid_name = NULL;
+
+	ast_set_callerid(p->chan,
+		p->owner->cid.cid_num, p->owner->cid.cid_name,
+		p->owner->cid.cid_ani ? p->chan->cid.cid_ani : p->owner->cid.cid_num);
 
 	if (p->owner->cid.cid_rdnis)
 		p->chan->cid.cid_rdnis = strdup(p->owner->cid.cid_rdnis);
 	else
 		p->chan->cid.cid_rdnis = NULL;
-
-	if (p->owner->cid.cid_ani)
-		p->chan->cid.cid_ani = strdup(p->owner->cid.cid_ani);
-	else
-		p->chan->cid.cid_ani = NULL;
 
 	p->chan->cid.cid_pres = p->owner->cid.cid_pres;
 

Modified: team/crichter/0.3.0/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/chan_mgcp.c?rev=36799&r1=36798&r2=36799&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/chan_mgcp.c (original)
+++ team/crichter/0.3.0/channels/chan_mgcp.c Mon Jul  3 02:55:01 2006
@@ -1428,10 +1428,7 @@
 		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);
-		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);
+		ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
 		if (!i->adsi)
 			tmp->adsicpe = AST_ADSI_UNAVAILABLE;
 		tmp->priority = 1;
@@ -2621,21 +2618,10 @@
 					/*res = tone_zone_play_tone(p->subs[index].zfd, -1);*/
 					ast_indicate(chan, -1);
 					strncpy(chan->exten, exten, sizeof(chan->exten)-1);
-					if (!ast_strlen_zero(p->cid_num)) {
-						if (!p->hidecallerid) {
-							/* SC: free existing chan->callerid */
-							if (chan->cid.cid_num)
-								free(chan->cid.cid_num);
-							chan->cid.cid_num = strdup(p->cid_num);
-							/* SC: free existing chan->callerid */
-							if (chan->cid.cid_name)
-								free(chan->cid.cid_name);
-							chan->cid.cid_name = strdup(p->cid_name);
-						}
-						if (chan->cid.cid_ani)
-							free(chan->cid.cid_ani);
-						chan->cid.cid_ani = strdup(p->cid_num);
-					}
+					ast_set_callerid(chan,
+							p->hidecallerid ? "" : p->cid_num,
+							p->hidecallerid ? "" : p->cid_name,
+							chan->cid.cid_ani ? NULL : p->cid_num);
 					ast_setstate(chan, AST_STATE_RING);
 					/*zt_enable_ec(p);*/
 					if (p->dtmfmode & MGCP_DTMF_HYBRID) {
@@ -2692,12 +2678,7 @@
 			}
 			/* Disable Caller*ID if enabled */
 			p->hidecallerid = 1;
-			if (chan->cid.cid_num)
-				free(chan->cid.cid_num);
-			chan->cid.cid_num = NULL;
-			if (chan->cid.cid_name)
-				free(chan->cid.cid_name);
-			chan->cid.cid_name = NULL;
+			ast_set_callerid(chan, "", "", NULL);
 			/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
 			transmit_notify_request(sub, "L/sl");
 			len = 0;
@@ -2776,14 +2757,7 @@
 			}
 			/* Enable Caller*ID if enabled */
 			p->hidecallerid = 0;
-			if (chan->cid.cid_num)
-				free(chan->cid.cid_num);
-			if (!ast_strlen_zero(p->cid_num))
-				chan->cid.cid_num = strdup(p->cid_num);
-			if (chan->cid.cid_name)
-				free(chan->cid.cid_name);
-			if (!ast_strlen_zero(p->cid_name))
-				chan->cid.cid_name = strdup(p->cid_name);
+			ast_set_callerid(chan, p->cid_num, p->cid_name, NULL);
 			/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
 			transmit_notify_request(sub, "L/sl");
 			len = 0;

Modified: team/crichter/0.3.0/channels/chan_modem.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/chan_modem.c?rev=36799&r1=36798&r2=36799&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/chan_modem.c (original)
+++ team/crichter/0.3.0/channels/chan_modem.c Mon Jul  3 02:55:01 2006
@@ -576,10 +576,7 @@
 		tmp->tech_pvt = i;
 		strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
 
-		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);
+		ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
 
 		if (!ast_strlen_zero(i->language))
 			strncpy(tmp->language,i->language, sizeof(tmp->language)-1);

Modified: team/crichter/0.3.0/channels/chan_phone.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/chan_phone.c?rev=36799&r1=36798&r2=36799&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/chan_phone.c (original)
+++ team/crichter/0.3.0/channels/chan_phone.c Mon Jul  3 02:55:01 2006
@@ -825,10 +825,7 @@
 			strncpy(tmp->exten, "s",  sizeof(tmp->exten) - 1);
 		if (!ast_strlen_zero(i->language))
 			strncpy(tmp->language, i->language, sizeof(tmp->language)-1);
-		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);
+		ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
 		i->owner = tmp;
 		ast_mutex_lock(&usecnt_lock);
 		usecnt++;

Modified: team/crichter/0.3.0/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/chan_sip.c?rev=36799&r1=36798&r2=36799&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/chan_sip.c (original)
+++ team/crichter/0.3.0/channels/chan_sip.c Mon Jul  3 02:55:01 2006
@@ -2817,10 +2817,7 @@
 	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));
-	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);
+	ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
 	if (!ast_strlen_zero(i->rdnis))
 		tmp->cid.cid_rdnis = strdup(i->rdnis);
 	if (!ast_strlen_zero(i->exten) && strcmp(i->exten, "s"))

Modified: team/crichter/0.3.0/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/chan_skinny.c?rev=36799&r1=36798&r2=36799&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/chan_skinny.c (original)
+++ team/crichter/0.3.0/channels/chan_skinny.c Mon Jul  3 02:55:01 2006
@@ -1741,11 +1741,12 @@
                     			getforward = 0;
                 		} else  {
                     			strncpy(chan->exten, exten, sizeof(chan->exten)-1);
+
                     			if (!ast_strlen_zero(l->cid_num)) {
-                        			if (!l->hidecallerid) {
-                            				chan->cid.cid_num = strdup(l->cid_num);
-                        				chan->cid.cid_ani = strdup(l->cid_num);
-                    				}
+						ast_set_callerid(chan,
+							l->hidecallerid ? "" : l->cid_num,
+							l->hidecallerid ? "" : l->cid_name,
+							chan->cid.cid_ani ? NULL : l->cid_num);
                     				ast_setstate(chan, AST_STATE_RING);
                     				res = ast_pbx_run(chan);
                     				if (res) {
@@ -1792,14 +1793,7 @@
             		}
 		       	/* Disable Caller*ID if enabled */
 		        l->hidecallerid = 1;
-       			if (chan->cid.cid_num) {
-	               		free(chan->cid.cid_num);
-	    		}
-	            	chan->cid.cid_num = NULL;
-	   		if (chan->cid.cid_name) {
-               			free(chan->cid.cid_name);
-	    		}
-	      		chan->cid.cid_name = NULL;
+			ast_set_callerid(chan, "", "", NULL);
             		transmit_tone(s, SKINNY_DIALTONE);
        			len = 0;
            		memset(exten, 0, sizeof(exten));
@@ -1873,18 +1867,7 @@
        			}
        			/* Enable Caller*ID if enabled */
        			l->hidecallerid = 0;
-       			if (chan->cid.cid_num) {
-              			free(chan->cid.cid_num);	
-    			}
-            		if (!ast_strlen_zero(l->cid_num)) {
-                		chan->cid.cid_num = strdup(l->cid_num);
-	    		}
-      			if (chan->cid.cid_name) {
-               			free(chan->cid.cid_name);
-    			}
-            		if (!ast_strlen_zero(l->cid_name)) {
-               			chan->cid.cid_name = strdup(l->cid_name);	
-			}
+			ast_set_callerid(chan, l->cid_num, l->cid_name, NULL);
             		transmit_tone(s, SKINNY_DIALTONE);
             		len = 0;
             		memset(exten, 0, sizeof(exten));
@@ -2296,12 +2279,7 @@
 		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);
-		if (!ast_strlen_zero(l->cid_num)) {
-			tmp->cid.cid_num = strdup(l->cid_num);
-		}
-		if (!ast_strlen_zero(l->cid_name)) {
-			tmp->cid.cid_name = strdup(l->cid_name);
-		}
+		ast_set_callerid(tmp, l->cid_num, l->cid_name, l->cid_num);
 		tmp->priority = 1;
 		tmp->adsicpe = AST_ADSI_UNAVAILABLE;
 



More information about the asterisk-commits mailing list