[asterisk-commits] murf: branch murf/CDRfix5 r67163 - in /team/murf/CDRfix5: ./ channels/ main/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Jun 4 16:45:04 MST 2007


Author: murf
Date: Mon Jun  4 18:45:03 2007
New Revision: 67163

URL: http://svn.digium.com/view/asterisk?view=rev&rev=67163
Log:
Merged revisions 67095,67120,67122,67157,67160 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r67095 | murf | 2007-06-04 16:15:38 -0600 (Mon, 04 Jun 2007) | 9 lines

Merged revisions 67073 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r67073 | murf | 2007-06-04 15:59:34 -0600 (Mon, 04 Jun 2007) | 1 line

This typo has been here since 1.4 forked. It has been the source of heartburn to many a dialplan/CDR programmer.
........

................
r67120 | russell | 2007-06-04 16:29:43 -0600 (Mon, 04 Jun 2007) | 14 lines

Merged revisions 67119 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r67119 | russell | 2007-06-04 17:28:55 -0500 (Mon, 04 Jun 2007) | 6 lines

Add comments for two functions that get called with the appropriate call locked,
but perform operations that could result in the pvt structure getting destroyed
before returning again, causing numerous seg faults all over the module.
(inspired by issues #9642, #9569, and #9666, and the work done by stevedavies
 and mihai)

........

................
r67122 | qwell | 2007-06-04 16:39:10 -0600 (Mon, 04 Jun 2007) | 12 lines

Merged revisions 67121 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r67121 | qwell | 2007-06-04 17:36:57 -0500 (Mon, 04 Jun 2007) | 4 lines

Fixes for dtmf/dialing with mgcp (similar to the recent fix for chan_skinny)

Issue 9855, patch by DEA.

........

................
r67157 | qwell | 2007-06-04 17:29:22 -0600 (Mon, 04 Jun 2007) | 14 lines

Merged revisions 67156 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r67156 | qwell | 2007-06-04 18:26:28 -0500 (Mon, 04 Jun 2007) | 6 lines

Fix for skinny keepalives.
If there is no traffic from the phone for (keep_alive * 1100) ms (arbitrarily
 adding 10% for network issues, etc),  unregister the device.

Issue 8394, patch by DEA.

........

................
r67160 | russell | 2007-06-04 17:32:26 -0600 (Mon, 04 Jun 2007) | 13 lines

Merged revisions 67158 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r67158 | russell | 2007-06-04 18:31:40 -0500 (Mon, 04 Jun 2007) | 5 lines

Fix up a bunch of places where the iax2 pvt structure can disappear and the
code did not account for it and crashes.
(issues #9642, #9569, #9666, probably others ... based on the work by
 stevedavies and mihai, with additional changes from me)

........

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

Modified:
    team/murf/CDRfix5/   (props changed)
    team/murf/CDRfix5/channels/chan_iax2.c
    team/murf/CDRfix5/channels/chan_mgcp.c
    team/murf/CDRfix5/channels/chan_skinny.c
    team/murf/CDRfix5/main/cdr.c

Propchange: team/murf/CDRfix5/
------------------------------------------------------------------------------
    automerge = yes

Propchange: team/murf/CDRfix5/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/murf/CDRfix5/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jun  4 18:45:03 2007
@@ -1,1 +1,1 @@
-/trunk:1-67085
+/trunk:1-67160

Modified: team/murf/CDRfix5/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/murf/CDRfix5/channels/chan_iax2.c?view=diff&rev=67163&r1=67162&r2=67163
==============================================================================
--- team/murf/CDRfix5/channels/chan_iax2.c (original)
+++ team/murf/CDRfix5/channels/chan_iax2.c Mon Jun  4 18:45:03 2007
@@ -1393,6 +1393,16 @@
 	iax_frame_free(fr);
 }
 
+/*!
+ * \brief Queue a frame to a call's owning asterisk channel
+ *
+ * \note This function assumes that iaxsl[callno] is locked when called.
+ *
+ * \note IMPORTANT NOTE!!! Any time this function is used, even if iaxs[callno]
+ * was valid before calling it, it may no longer be valid after calling it.
+ * This function may unlock and lock the mutex associated with this callno,
+ * meaning that another thread may grab it and destroy the call.
+ */
 static int iax2_queue_frame(int callno, struct ast_frame *f)
 {
 	/* Assumes lock for callno is already held... */
@@ -1664,6 +1674,14 @@
 	AST_LIST_UNLOCK(&firmwares);
 }
 
+/*!
+ * \note This function assumes that iaxsl[callno] is locked when called.
+ *
+ * \note IMPORTANT NOTE!!! Any time this function is used, even if iaxs[callno]
+ * was valid before calling it, it may no longer be valid after calling it.
+ * This function calls iax2_queue_frame(), which may unlock and lock the mutex 
+ * associated with this callno, meaning that another thread may grab it and destroy the call.
+ */
 static int __do_deliver(void *data)
 {
 	/* Just deliver the packet by using queueing.  This is called by
@@ -1932,9 +1950,9 @@
 							/* Hangup the fd */
 							fr.frametype = AST_FRAME_CONTROL;
 							fr.subclass = AST_CONTROL_HANGUP;
-							iax2_queue_frame(callno, &fr);
+							iax2_queue_frame(callno, &fr); // XXX
 							/* Remember, owner could disappear */
-							if (iaxs[callno]->owner)
+							if (iaxs[callno] && iaxs[callno]->owner)
 								iaxs[callno]->owner->hangupcause = AST_CAUSE_DESTINATION_OUT_OF_ORDER;
 						} else {
 							if (iaxs[callno]->reg) {
@@ -2370,6 +2388,8 @@
 		case JB_OK:
 			fr = frame.data;
 			__do_deliver(fr);
+			/* __do_deliver() can cause the call to disappear */
+			pvt = iaxs[callno];
 			break;
 		case JB_INTERP:
 		{
@@ -2385,10 +2405,13 @@
 			
 			/* queue the frame:  For consistency, we would call __do_deliver here, but __do_deliver wants an iax_frame,
 			 * which we'd need to malloc, and then it would free it.  That seems like a drag */
-			if (!ast_test_flag(iaxs[callno], IAX_ALREADYGONE))
+			if (!ast_test_flag(iaxs[callno], IAX_ALREADYGONE)) {
 				iax2_queue_frame(callno, &af);
-		}
-		break;
+				/* iax2_queue_frame() could cause the call to disappear */
+				pvt = iaxs[callno];
+			}
+		}
+			break;
 		case JB_DROP:
 			iax2_frame_free(frame.data);
 			break;
@@ -2401,7 +2424,8 @@
 			break;
 		}
 	}
-	update_jbsched(pvt);
+	if (pvt)
+		update_jbsched(pvt);
 	ast_mutex_unlock(&iaxsl[callno]);
 }
 
@@ -2414,6 +2438,12 @@
 	return 0;
 }
 
+/*!
+ * \note This function assumes fr->callno is locked
+ *
+ * \note IMPORTANT NOTE!!! Any time this function is used, even if iaxs[callno]
+ * was valid before calling it, it may no longer be valid after calling it.
+ */
 static int schedule_delivery(struct iax_frame *fr, int updatehistory, int fromtrunk, unsigned int *tsout)
 {
 	int type, len;
@@ -2422,7 +2452,6 @@
 
 	/* Attempt to recover wrapped timestamps */
 	unwrap_timestamp(fr);
-	
 
 	/* delivery time is sender's sent timestamp converted back into absolute time according to our clock */
 	if ( !fromtrunk && !ast_tvzero(iaxs[fr->callno]->rxcore))
@@ -2457,16 +2486,20 @@
 	if( (!ast_test_flag(iaxs[fr->callno], IAX_FORCEJITTERBUF)) &&
 	    iaxs[fr->callno]->owner && ast_bridged_channel(iaxs[fr->callno]->owner) &&
 	    (ast_bridged_channel(iaxs[fr->callno]->owner)->tech->properties & AST_CHAN_TP_WANTSJITTER)) {
-                jb_frame frame;
-
-                /* deliver any frames in the jb */
-                while(jb_getall(iaxs[fr->callno]->jb,&frame) == JB_OK)
-                        __do_deliver(frame.data);
+		jb_frame frame;
+
+		/* deliver any frames in the jb */
+		while (jb_getall(iaxs[fr->callno]->jb, &frame) == JB_OK) {
+			__do_deliver(frame.data);
+			/* __do_deliver() can make the call disappear */
+			if (!iaxs[fr->callno])
+				return -1;
+		}
 
 		jb_reset(iaxs[fr->callno]->jb);
 
 		if (iaxs[fr->callno]->jbid > -1)
-                        ast_sched_del(sched, iaxs[fr->callno]->jbid);
+			ast_sched_del(sched, iaxs[fr->callno]->jbid);
 
 		iaxs[fr->callno]->jbid = -1;
 
@@ -3208,6 +3241,10 @@
 	struct timeval waittimer = {0, 0}, tv;
 
 	lock_both(callno0, callno1);
+	if (!iaxs[callno0] || !iaxs[callno1]) {
+		unlock_both(callno0, callno1);
+		return AST_BRIDGE_FAILED;
+	}
 	/* Put them in native bridge mode */
 	if (!flags & (AST_BRIDGE_DTMF_CHANNEL_0 | AST_BRIDGE_DTMF_CHANNEL_1)) {
 		iaxs[callno0]->bridgecallno = callno1;
@@ -3246,8 +3283,10 @@
 			}
 			/* Remove from native mode */
 			lock_both(callno0, callno1);
-			iaxs[callno0]->bridgecallno = 0;
-			iaxs[callno1]->bridgecallno = 0;
+			if (iaxs[callno0])
+				iaxs[callno0]->bridgecallno = 0;
+			if (iaxs[callno1])
+				iaxs[callno1]->bridgecallno = 0;
 			unlock_both(callno0, callno1);
 			return AST_BRIDGE_FAILED_NOWARN;
 		}
@@ -7077,6 +7116,10 @@
 					ast_mutex_unlock(&iaxsl[fr->callno]);
 					exists = ast_exists_extension(NULL, iaxs[fr->callno]->context, iaxs[fr->callno]->exten, 1, iaxs[fr->callno]->cid_num);
 					ast_mutex_lock(&iaxsl[fr->callno]);
+					if (!iaxs[fr->callno]) {
+						ast_mutex_unlock(&iaxsl[fr->callno]);
+						return 1;
+					}
 				} else
 					exists = 0;
 				/* Get OSP token if it does exist */
@@ -7827,7 +7870,7 @@
 			return 1;
 		}
 		/* Unless this is an ACK or INVAL frame, ack it */
-		if (iaxs[fr->callno]->aseqno != iaxs[fr->callno]->iseqno)
+		if (iaxs[fr->callno] && iaxs[fr->callno]->aseqno != iaxs[fr->callno]->iseqno)
 			send_command_immediate(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACK, fr->ts, NULL, 0,fr->iseqno);
 	} else if (minivid) {
 		f.frametype = AST_FRAME_VIDEO;

Modified: team/murf/CDRfix5/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/team/murf/CDRfix5/channels/chan_mgcp.c?view=diff&rev=67163&r1=67162&r2=67163
==============================================================================
--- team/murf/CDRfix5/channels/chan_mgcp.c (original)
+++ team/murf/CDRfix5/channels/chan_mgcp.c Mon Jun  4 18:45:03 2007
@@ -323,6 +323,7 @@
 	char cid_num[AST_MAX_EXTENSION];	/*!< Caller*ID number */
 	char cid_name[AST_MAX_EXTENSION];	/*!< Caller*ID name */
 	char lastcallerid[AST_MAX_EXTENSION];	/*!< Last Caller*ID */
+	char dtmf_buf[AST_MAX_EXTENSION];	/*!< place to collect digits be */
 	char call_forward[AST_MAX_EXTENSION];	/*!< Last Caller*ID */
 	char musicclass[MAX_MUSICCLASS];
 	char curtone[80];			/*!< Current tone */
@@ -2639,27 +2640,31 @@
 	struct ast_channel *chan = data;
 	struct mgcp_subchannel *sub = chan->tech_pvt;
 	struct mgcp_endpoint *p = sub->parent;
-	char exten[AST_MAX_EXTENSION] = "";
+	/* char exten[AST_MAX_EXTENSION] = ""; */
 	int len = 0;
 	int timeout = firstdigittimeout;
-	int res;
+	int res= 0;
 	int getforward = 0;
+	int loop_pause = 100;
+
+	len = strlen(p->dtmf_buf);
 
 	while(len < AST_MAX_EXTENSION-1) {
-		res = ast_waitfordigit(chan, timeout);
+		res = 1;  /* Assume that we will get a digit */
+		while (strlen(p->dtmf_buf) == len){
+			ast_safe_sleep(chan, loop_pause);
+			timeout -= loop_pause;
+			if ( (timeout -= loop_pause) <= 0){
+				res = 0;
+				break;
+			}
+			res = 1;
+		}
+
 		timeout = 0;
-		if (res < 0) {
-			if (option_debug)
-				ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n");
-			/*res = tone_zone_play_tone(p->subs[index].zfd, -1);*/
-			ast_indicate(chan, -1);
-			ast_hangup(chan);
-			return NULL;
-		} else if (res) {
-			exten[len++]=res;
-			exten[len] = '\0';
-		}
-		if (!ast_ignore_pattern(chan->context, exten)) {
+		len = strlen(p->dtmf_buf);
+
+		if (!ast_ignore_pattern(chan->context, p->dtmf_buf)) {
 			/*res = tone_zone_play_tone(p->subs[index].zfd, -1);*/
 			ast_indicate(chan, -1);
 		} else {
@@ -2667,11 +2672,11 @@
 			/*tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALTONE);*/
 			transmit_notify_request(sub, "L/dl");
 		}
-		if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num)) {
-			if (!res || !ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) {
+		if (ast_exists_extension(chan, chan->context, p->dtmf_buf, 1, p->cid_num)) {
+			if (!res || !ast_matchmore_extension(chan, chan->context, p->dtmf_buf, 1, p->cid_num)) {
 				if (getforward) {
 					/* Record this as the forwarding extension */
-					ast_copy_string(p->call_forward, exten, sizeof(p->call_forward)); 
+					ast_copy_string(p->call_forward, p->dtmf_buf, sizeof(p->call_forward)); 
 					if (option_verbose > 2) {
 						ast_verbose(VERBOSE_PREFIX_3 "Setting call forward to '%s' on channel %s\n", 
 							p->call_forward, chan->name);
@@ -2684,7 +2689,7 @@
 					/*res = tone_zone_play_tone(p->subs[index].zfd, -1);*/
 					ast_indicate(chan, -1);
 					sleep(1);
-					memset(exten, 0, sizeof(exten));
+					memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
 					/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALTONE);*/
 					transmit_notify_request(sub, "L/dl");
 					len = 0;
@@ -2692,7 +2697,8 @@
 				} else {
 					/*res = tone_zone_play_tone(p->subs[index].zfd, -1);*/
 					ast_indicate(chan, -1);
-					ast_copy_string(chan->exten, exten, sizeof(chan->exten));
+					ast_copy_string(chan->exten, p->dtmf_buf, sizeof(chan->exten));
+					memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
 					ast_set_callerid(chan,
 						p->hidecallerid ? "" : p->cid_num,
 						p->hidecallerid ? "" : p->cid_name,
@@ -2725,7 +2731,7 @@
 			/*zt_wait_event(p->subs[index].zfd);*/
 			ast_hangup(chan);
 			return NULL;
-		} else if (p->hascallwaiting && p->callwaiting && !strcmp(exten, "*70")) {
+		} else if (p->hascallwaiting && p->callwaiting && !strcmp(p->dtmf_buf, "*70")) {
 			if (option_verbose > 2) {
 				ast_verbose(VERBOSE_PREFIX_3 "Disabling call waiting on %s\n", chan->name);
 			}
@@ -2734,9 +2740,9 @@
 			/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
 			transmit_notify_request(sub, "L/sl");
 			len = 0;
-			memset(exten, 0, sizeof(exten));
+			memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
 			timeout = firstdigittimeout;
-		} else if (!strcmp(exten,ast_pickup_ext())) {
+		} else if (!strcmp(p->dtmf_buf,ast_pickup_ext())) {
 			/* Scan all channels and see if any there
 			 * ringing channqels with that have call groups
 			 * that equal this channels pickup group  
@@ -2746,9 +2752,10 @@
 				/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION);*/
 				transmit_notify_request(sub, "G/cg");
 			}
+			memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
 			ast_hangup(chan);
 			return NULL;
-		} else if (!p->hidecallerid && !strcmp(exten, "*67")) {
+		} else if (!p->hidecallerid && !strcmp(p->dtmf_buf, "*67")) {
 			if (option_verbose > 2) {
 				ast_verbose(VERBOSE_PREFIX_3 "Disabling Caller*ID on %s\n", chan->name);
 			}
@@ -2758,9 +2765,9 @@
 			/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
 			transmit_notify_request(sub, "L/sl");
 			len = 0;
-			memset(exten, 0, sizeof(exten));
+			memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
 			timeout = firstdigittimeout;
-		} else if (p->callreturn && !strcmp(exten, "*69")) {
+		} else if (p->callreturn && !strcmp(p->dtmf_buf, "*69")) {
 			res = 0;
 			if (!ast_strlen_zero(p->lastcallerid)) {
 				res = ast_say_digit_str(chan, p->lastcallerid, "", chan->language);
@@ -2769,7 +2776,7 @@
 				/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
 				transmit_notify_request(sub, "L/sl");
 			break;
-		} else if (!strcmp(exten, "*78")) {
+		} else if (!strcmp(p->dtmf_buf, "*78")) {
 			/* Do not disturb */
 			if (option_verbose > 2) {
 				ast_verbose(VERBOSE_PREFIX_3 "Enabled DND on channel %s\n", chan->name);
@@ -2778,9 +2785,9 @@
 			transmit_notify_request(sub, "L/sl");
 			p->dnd = 1;
 			getforward = 0;
-			memset(exten, 0, sizeof(exten));
+			memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
 			len = 0;
-		} else if (!strcmp(exten, "*79")) {
+		} else if (!strcmp(p->dtmf_buf, "*79")) {
 			/* Do not disturb */
 			if (option_verbose > 2) {
 				ast_verbose(VERBOSE_PREFIX_3 "Disabled DND on channel %s\n", chan->name);
@@ -2789,15 +2796,15 @@
 			transmit_notify_request(sub, "L/sl");
 			p->dnd = 0;
 			getforward = 0;
-			memset(exten, 0, sizeof(exten));
+			memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
 			len = 0;
-		} else if (p->cancallforward && !strcmp(exten, "*72")) {
+		} else if (p->cancallforward && !strcmp(p->dtmf_buf, "*72")) {
 			/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
 			transmit_notify_request(sub, "L/sl");
 			getforward = 1;
-			memset(exten, 0, sizeof(exten));
+			memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
 			len = 0;
-		} else if (p->cancallforward && !strcmp(exten, "*73")) {
+		} else if (p->cancallforward && !strcmp(p->dtmf_buf, "*73")) {
 			if (option_verbose > 2) {
 				ast_verbose(VERBOSE_PREFIX_3 "Cancelling call forwarding on channel %s\n", chan->name);
 			}
@@ -2805,9 +2812,9 @@
 			transmit_notify_request(sub, "L/sl");
 			memset(p->call_forward, 0, sizeof(p->call_forward));
 			getforward = 0;
-			memset(exten, 0, sizeof(exten));
+			memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
 			len = 0;
-		} else if (!strcmp(exten, ast_parking_ext()) && 
+		} else if (!strcmp(p->dtmf_buf, ast_parking_ext()) && 
 			sub->next->owner && ast_bridged_channel(sub->next->owner)) {
 			/* This is a three way call, the main call being a real channel, 
 			   and we're parking the first call. */
@@ -2816,7 +2823,7 @@
 				ast_verbose(VERBOSE_PREFIX_3 "Parking call to '%s'\n", chan->name);
 			}
 			break;
-		} else if (!ast_strlen_zero(p->lastcallerid) && !strcmp(exten, "*60")) {
+		} else if (!ast_strlen_zero(p->lastcallerid) && !strcmp(p->dtmf_buf, "*60")) {
 			if (option_verbose > 2) {
 				ast_verbose(VERBOSE_PREFIX_3 "Blacklisting number %s\n", p->lastcallerid);
 			}
@@ -2824,10 +2831,10 @@
 			if (!res) {
 				/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
 				transmit_notify_request(sub, "L/sl");
-				memset(exten, 0, sizeof(exten));
+				memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
 				len = 0;
 			}
-		} else if (p->hidecallerid && !strcmp(exten, "*82")) {
+		} else if (p->hidecallerid && !strcmp(p->dtmf_buf, "*82")) {
 			if (option_verbose > 2) {
 				ast_verbose(VERBOSE_PREFIX_3 "Enabling Caller*ID on %s\n", chan->name);
 			}
@@ -2837,17 +2844,17 @@
 			/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
 			transmit_notify_request(sub, "L/sl");
 			len = 0;
-			memset(exten, 0, sizeof(exten));
+			memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
 			timeout = firstdigittimeout;
-		} else if (!ast_canmatch_extension(chan, chan->context, exten, 1, chan->cid.cid_num) &&
-				((exten[0] != '*') || (strlen(exten) > 2))) {
+		} else if (!ast_canmatch_extension(chan, chan->context, p->dtmf_buf, 1, chan->cid.cid_num) &&
+				((p->dtmf_buf[0] != '*') || (strlen(p->dtmf_buf) > 2))) {
 			if (option_debug)
-				ast_log(LOG_DEBUG, "Can't match %s from '%s' in context %s\n", exten, chan->cid.cid_num ? chan->cid.cid_num : "<Unknown Caller>", chan->context);
+				ast_log(LOG_DEBUG, "Can't match %s from '%s' in context %s\n", p->dtmf_buf, chan->cid.cid_num ? chan->cid.cid_num : "<Unknown Caller>", chan->context);
 			break;
 		}
 		if (!timeout)
 			timeout = gendigittimeout;
-		if (len && !ast_ignore_pattern(chan->context, exten))
+		if (len && !ast_ignore_pattern(chan->context, p->dtmf_buf))
 			/*tone_zone_play_tone(p->subs[index].zfd, -1);*/
 			ast_indicate(chan, -1);
 	}
@@ -2885,11 +2892,14 @@
 		chan->rings = 1;
 		if (ast_pbx_run(chan)) {
 			ast_log(LOG_WARNING, "Unable to launch PBX on %s\n", chan->name);
-		} else
+		} else {
+			memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
 			return NULL;
+		}
 	}
 #endif
 	ast_hangup(chan);
+	memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
 	return NULL;
 }
 
@@ -3266,20 +3276,25 @@
 				(((ev[0] >= '0') && (ev[0] <= '9')) ||
 				 ((ev[0] >= 'A') && (ev[0] <= 'D')) ||
 				  (ev[0] == '*') || (ev[0] == '#'))) {
-			f.frametype = AST_FRAME_DTMF;
-			f.subclass = ev[0];
-			f.src = "mgcp";
-			if (sub->owner) {
-				/* XXX MUST queue this frame to all subs in threeway call if threeway call is active */
-				mgcp_queue_frame(sub, &f);
-				ast_mutex_lock(&sub->next->lock);
-				if (sub->next->owner) {
-					mgcp_queue_frame(sub->next, &f);
+			if (sub && (sub->owner->_state >=  AST_STATE_UP)) {
+				f.frametype = AST_FRAME_DTMF;
+				f.subclass = ev[0];
+				f.src = "mgcp";
+				if (sub->owner) {
+					/* XXX MUST queue this frame to all subs in threeway call if threeway call is active */
+					mgcp_queue_frame(sub, &f);
+					ast_mutex_lock(&sub->next->lock);
+					if (sub->next->owner) {
+						mgcp_queue_frame(sub->next, &f);
+					}
+					ast_mutex_unlock(&sub->next->lock);
 				}
-				ast_mutex_unlock(&sub->next->lock);
-			}
-			if (strstr(p->curtone, "wt") && (ev[0] == 'A')) {
-				memset(p->curtone, 0, sizeof(p->curtone));
+				if (strstr(p->curtone, "wt") && (ev[0] == 'A')) {
+					memset(p->curtone, 0, sizeof(p->curtone));
+				}
+			} else {
+				p->dtmf_buf[strlen(p->dtmf_buf)] = ev[0];
+				p->dtmf_buf[strlen(p->dtmf_buf)] = '\0';
 			}
 		} else if (!strcasecmp(ev, "T")) {
 			/* Digit timeout -- unimportant */

Modified: team/murf/CDRfix5/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/murf/CDRfix5/channels/chan_skinny.c?view=diff&rev=67163&r1=67162&r2=67163
==============================================================================
--- team/murf/CDRfix5/channels/chan_skinny.c (original)
+++ team/murf/CDRfix5/channels/chan_skinny.c Mon Jun  4 18:45:03 2007
@@ -4438,15 +4438,21 @@
  	fds[0].fd = s->fd;
 	fds[0].events = POLLIN;
 	fds[0].revents = 0;
-	res = poll(fds, 1, -1);
-
+	res = poll(fds, 1, (keep_alive * 1100)); /* If nothing has happen, client is dead */
+						 /* we add 10% to the keep_alive to deal */
+						 /* with network delays, etc */
 	if (res < 0) {
-		if (errno != EINTR)
-		{
+		if (errno != EINTR) {
 			ast_log(LOG_WARNING, "Select returned error: %s\n", strerror(errno));
 			return res;
 		}
- 	}
+ 	} else if (res == 0) {
+		if (skinnydebug)
+			ast_verbose("Skinny Client was lost, unregistering\n");
+		skinny_unregister(NULL, s);
+		return -1;
+	}
+		     
 	if (fds[0].revents) {
 		ast_mutex_lock(&s->lock);
 		memset(s->inbuf,0,sizeof(s->inbuf));

Modified: team/murf/CDRfix5/main/cdr.c
URL: http://svn.digium.com/view/asterisk/team/murf/CDRfix5/main/cdr.c?view=diff&rev=67163&r1=67162&r2=67163
==============================================================================
--- team/murf/CDRfix5/main/cdr.c (original)
+++ team/murf/CDRfix5/main/cdr.c Mon Jun  4 18:45:03 2007
@@ -754,7 +754,7 @@
 int ast_cdr_setcid(struct ast_cdr *cdr, struct ast_channel *c)
 {
 	for (; cdr; cdr = cdr->next) {
-		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) /* I may be shooting myself here, but why on earth would we ever want to just the cid's of locked CDR's ???? */
+		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED))
 			set_one_cid(cdr, c);
 	}
 	return 0;



More information about the asterisk-commits mailing list