[svn-commits] murf: branch group/newcdr r163487 - in /team/group/newcdr: ./ apps/ configs/ ...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Dec 12 08:25:37 CST 2008


Author: murf
Date: Fri Dec 12 08:25:36 2008
New Revision: 163487

URL: http://svn.digium.com/view/asterisk?view=rev&rev=163487
Log:
Merged revisions 163166,163168,163171,163198,163213,163241,163254,163317,163384 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
  r163166 | mmichelson | 2008-12-11 12:40:18 -0700 (Thu, 11 Dec 2008) | 3 lines
  
  Reduce indentation level of ast_feature_request_and_dial
................
  r163168 | tilghman | 2008-12-11 13:02:35 -0700 (Thu, 11 Dec 2008) | 5 lines
  
  Sometimes even Linux needs -lm to link libtonezone, such as when libtonezone
  is compiled statically.
  (closes issue #13887)
   Reported by: tzafrir
................
  r163171 | russell | 2008-12-11 13:07:47 -0700 (Thu, 11 Dec 2008) | 16 lines
  
  Fix the "failed" extension for outgoing calls.  
  
  The conversion to use ast_check_hangup() everywhere instead of checking the softhangup
  flag directly introduced this problem.  The issue is that ast_check_hangup() checked
  for tech_pvt to be NULL.  Unfortunately, this will be NULL is some valid circumstances,
  such as with a dummy channel.
  
  The fix is simple.  Don't check tech_pvt.  It's pointless, because the code path that
  sets this to NULL is when the channel hangup callback gets called.  This happens inside
  of ast_hangup(), which is the same function responsible for freeing the channel.  Any
  code calling ast_check_hangup() better not be calling it after that point, and if so,
  we have a bigger problem at hand.
  
  (closes issue #14035)
  Reported by: erogoza
................
  r163198 | mmichelson | 2008-12-11 13:21:44 -0700 (Thu, 11 Dec 2008) | 3 lines
  
  Add an appropriate goto if ast_call fails
................
  r163213 | mmichelson | 2008-12-11 13:57:44 -0700 (Thu, 11 Dec 2008) | 9 lines
  
  Add an option to voicemail.conf to allow urgent messages to be
  forwarded as not urgent.
  
  (closes issue #14063)
  Reported by: jaroth
  Patches:
        urgfwd_v2.patch uploaded by jaroth (license 50)
................
  r163241 | russell | 2008-12-11 14:21:31 -0700 (Thu, 11 Dec 2008) | 8 lines
  
  Fix a problem where continuous mode will get inadvertently get turned off if set_rate()
  is used while continuous mode was already turned on.
  
  (closes issue #13738)
  Reported by: smurfix
  Patches:
        res.patch.fixed uploaded by smurfix (license 547)
................
  r163254 | russell | 2008-12-11 14:48:08 -0700 (Thu, 11 Dec 2008) | 16 lines
  
  Merged revisions 163253 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
  r163253 | russell | 2008-12-11 15:46:29 -0600 (Thu, 11 Dec 2008) | 8 lines
  
  Fix some observed slowdowns in dialplan processing.
  
  The change is to remove autoservice usage from dialplan functions that do not
  need it because they do not perform operations that potentially block.
  
  (closes issue #13940)
  Reported by: tbelder
  
  ........
................
  r163317 | mnicholson | 2008-12-11 15:49:59 -0700 (Thu, 11 Dec 2008) | 16 lines
  
  Merged revisions 163316 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
    r163316 | mnicholson | 2008-12-11 16:44:31 -0600 (Thu, 11 Dec 2008) | 9 lines
    
    Clean up the dundi cache every 5 minutes.
    
    (closes issue #13819)
    Reported by: adomjan
    Patches:
          pbx_dundi.c-clearcache.patch uploaded by adomjan (license 487)
          dundi_clearecache3.diff uploaded by mnicholson (license 96)
    Tested by: adomjan
  ........
................
  r163384 | tilghman | 2008-12-11 16:38:56 -0700 (Thu, 11 Dec 2008) | 16 lines
  
  Merged revisions 163383 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
    r163383 | tilghman | 2008-12-11 17:35:55 -0600 (Thu, 11 Dec 2008) | 9 lines
    
    When a Ctrl-C or Ctrl-D ends a remote console, on certain shells, the terminal
    is messed up.  By intercepting those events with a signal handler in the remote
    console, we can avoid those issues.
    (closes issue #13464)
     Reported by: tzafrir
     Patches: 
           20081110__bug13464.diff.txt uploaded by Corydon76 (license 14)
     Tested by: blitzrage
  ........
................

Modified:
    team/group/newcdr/   (props changed)
    team/group/newcdr/apps/app_voicemail.c
    team/group/newcdr/configs/voicemail.conf.sample
    team/group/newcdr/configure
    team/group/newcdr/configure.ac
    team/group/newcdr/funcs/func_cut.c
    team/group/newcdr/funcs/func_strings.c
    team/group/newcdr/main/asterisk.c
    team/group/newcdr/main/channel.c
    team/group/newcdr/main/features.c
    team/group/newcdr/pbx/pbx_dundi.c
    team/group/newcdr/res/res_timing_pthread.c

Propchange: team/group/newcdr/
------------------------------------------------------------------------------
    automerge = si

Propchange: team/group/newcdr/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/group/newcdr/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Dec 12 08:25:36 2008
@@ -1,1 +1,1 @@
-/trunk:1-163108
+/trunk:1-163447

Modified: team/group/newcdr/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/apps/app_voicemail.c?view=diff&rev=163487&r1=163486&r2=163487
==============================================================================
--- team/group/newcdr/apps/app_voicemail.c (original)
+++ team/group/newcdr/apps/app_voicemail.c Fri Dec 12 08:25:36 2008
@@ -407,6 +407,7 @@
 #define VM_TEMPGREETWARN (1 << 15)  /*!< Remind user tempgreeting is set */
 #define VM_MOVEHEARD     (1 << 16)  /*!< Move a "heard" message to Old after listening to it */
 #define VM_MESSAGEWRAP   (1 << 17)  /*!< Wrap around from the last message to the first, and vice-versa */
+#define VM_FWDURGAUTO    (1 << 18)  /*!< Autoset of Urgent flag on forwarded Urgent messages set globally */
 #define ERROR_LOCK_PATH  -100
 
 
@@ -6267,7 +6268,9 @@
 	char urgent_str[7] = "";
 	char tmptxtfile[PATH_MAX];
 
-	ast_copy_string(urgent_str, urgent ? "Urgent" : "", sizeof(urgent_str));
+	if (ast_test_flag((&globalflags), VM_FWDURGAUTO)) {
+		ast_copy_string(urgent_str, urgent ? "Urgent" : "", sizeof(urgent_str));
+	}
 
 	if (vms == NULL) return -1;
 	dir = vms->curdir;
@@ -10663,6 +10666,12 @@
 		}
 		ast_set2_flag((&globalflags), ast_true(val), VM_MOVEHEARD);	
 
+		if (!(val = ast_variable_retrieve(cfg, "general", "forward_urgent_auto"))) {
+			ast_debug(1,"Autoset of Urgent flag on forwarded Urgent messages disabled globally\n");
+			val = "no";
+		}
+		ast_set2_flag((&globalflags), ast_true(val), VM_FWDURGAUTO);	
+
 		if (!(val = ast_variable_retrieve(cfg, "general", "sayduration"))) {
 			ast_debug(1,"Duration info before msg enabled globally\n");
 			val = "yes";

Modified: team/group/newcdr/configs/voicemail.conf.sample
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/configs/voicemail.conf.sample?view=diff&rev=163487&r1=163486&r2=163487
==============================================================================
--- team/group/newcdr/configs/voicemail.conf.sample (original)
+++ team/group/newcdr/configs/voicemail.conf.sample Fri Dec 12 08:25:36 2008
@@ -54,6 +54,10 @@
 ;
 ; Move heard messages to the 'Old' folder automagically.  Defaults to on.
 ;moveheard=yes
+;
+; Forward an urgent message as an urgent message.  Defaults to no so
+; sender can set the urgency on the envelope of the forwarded message.
+;forward_urgent_auto=no
 ;
 ; User context is where entries from users.conf are registered.  The
 ; default value is 'default'

Modified: team/group/newcdr/configure.ac
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/configure.ac?view=diff&rev=163487&r1=163486&r2=163487
==============================================================================
--- team/group/newcdr/configure.ac (original)
+++ team/group/newcdr/configure.ac Fri Dec 12 08:25:36 2008
@@ -1521,7 +1521,9 @@
 
 AST_EXT_LIB_CHECK([TINFO], [tinfo], [tgetent], [])
 
-if test "${host_os}" != "linux-gnu" ; then
+AC_CHECK_LIB([tonezone], [tone_zone_find_by_num], tonezone_does_not_need_lm=yes, tonezone_does_not_need_lm=no)
+
+if test "${tonezone_does_not_need_lm}" = "no" ; then
   tonezone_extra="-lm"
 fi
 

Modified: team/group/newcdr/funcs/func_cut.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/funcs/func_cut.c?view=diff&rev=163487&r1=163486&r2=163487
==============================================================================
--- team/group/newcdr/funcs/func_cut.c (original)
+++ team/group/newcdr/funcs/func_cut.c Fri Dec 12 08:25:36 2008
@@ -270,9 +270,6 @@
 {
 	int ret = -1;
 
-	if (chan)
-		ast_autoservice_start(chan);
-
 	switch (cut_internal(chan, data, buf, len)) {
 	case ERROR_NOARG:
 		ast_log(LOG_ERROR, "Syntax: CUT(<varname>,<char-delim>,<range-spec>) - missing argument!\n");
@@ -289,9 +286,6 @@
 	default:
 		ast_log(LOG_ERROR, "Unknown internal error\n");
 	}
-
-	if (chan)
-		ast_autoservice_stop(chan);
 
 	return ret;
 }

Modified: team/group/newcdr/funcs/func_strings.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/funcs/func_strings.c?view=diff&rev=163487&r1=163486&r2=163487
==============================================================================
--- team/group/newcdr/funcs/func_strings.c (original)
+++ team/group/newcdr/funcs/func_strings.c Fri Dec 12 08:25:36 2008
@@ -285,9 +285,6 @@
 	char delim[2] = "";
 	size_t delim_used;
 
-	if (chan)
-		ast_autoservice_start(chan);
-
 	AST_STANDARD_APP_ARGS(args, parse);
 	if (args.delim) {
 		ast_get_encoded_char(args.delim, delim, &delim_used);
@@ -306,9 +303,6 @@
 		fieldcount = 1;
 	}
 	snprintf(buf, len, "%d", fieldcount);
-
-	if (chan)
-		ast_autoservice_stop(chan);
 
 	return 0;
 }
@@ -565,9 +559,6 @@
 	value2 = ast_strdupa(value);
 	if (!var || !value2)
 		return -1;
-
-	if (chan)
-		ast_autoservice_start(chan);
 
 	if (!strcmp(cmd, "HASH")) {
 		const char *var2 = pbx_builtin_getvar_helper(chan, "~ODBCFIELDS~");
@@ -615,9 +606,6 @@
 		}
 	}
 
-	if (chan)
-		ast_autoservice_stop(chan);
-
 	return 0;
 }
 
@@ -855,11 +843,7 @@
 		return -1;
 	}
 
-	if (chan)
-		ast_autoservice_start(chan);
 	pbx_substitute_variables_helper(chan, data, buf, buflen - 1);
-	if (chan)
-		ast_autoservice_stop(chan);
 
 	return 0;
 }

Modified: team/group/newcdr/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/main/asterisk.c?view=diff&rev=163487&r1=163486&r2=163487
==============================================================================
--- team/group/newcdr/main/asterisk.c (original)
+++ team/group/newcdr/main/asterisk.c Fri Dec 12 08:25:36 2008
@@ -1529,6 +1529,11 @@
 	}
 	/* There is no need to restore the signal handler here, since the app
 	 * is going to exit */
+}
+
+static void __remote_quit_handler(int num)
+{
+	sig_flags.need_quit = 1;
 }
 
 static const char *fix_header(char *outbuf, int maxout, const char *s, char *cmp)
@@ -2458,6 +2463,11 @@
 	char *ebuf;
 	int num = 0;
 
+	memset(&sig_flags, 0, sizeof(sig_flags));
+	signal(SIGINT, __remote_quit_handler);
+	signal(SIGTERM, __remote_quit_handler);
+	signal(SIGHUP, __remote_quit_handler);
+
 	if (read(ast_consock, buf, sizeof(buf)) < 0) {
 		ast_log(LOG_ERROR, "read() failed: %s\n", strerror(errno));
 		return;
@@ -2468,6 +2478,9 @@
 		sprintf(tmp, "%s%s", prefix, data);
 		if (write(ast_consock, tmp, strlen(tmp) + 1) < 0) {
 			ast_log(LOG_ERROR, "write() failed: %s\n", strerror(errno));
+			if (sig_flags.need_quit == 1) {
+				return;
+			}
 		}
 	}
 	stringp = buf;
@@ -2503,6 +2516,10 @@
 			char buffer[512] = "", *curline = buffer, *nextline;
 			int not_written = 1;
 
+			if (sig_flags.need_quit == 1) {
+				break;
+			}
+
 			if (read(ast_consock, buffer, sizeof(buffer) - 1) <= 0) {
 				break;
 			}
@@ -2546,6 +2563,10 @@
 
 	for (;;) {
 		ebuf = (char *)el_gets(el, &num);
+
+		if (sig_flags.need_quit == 1) {
+			break;
+		}
 
 		if (!ebuf && write(1, "", 1) < 0)
 			break;

Modified: team/group/newcdr/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/main/channel.c?view=diff&rev=163487&r1=163486&r2=163487
==============================================================================
--- team/group/newcdr/main/channel.c (original)
+++ team/group/newcdr/main/channel.c Fri Dec 12 08:25:36 2008
@@ -462,8 +462,6 @@
 int ast_check_hangup(struct ast_channel *chan)
 {
 	if (chan->_softhangup)		/* yes if soft hangup flag set */
-		return 1;
-	if (!chan->tech_pvt)		/* yes if no technology private data */
 		return 1;
 	if (ast_tvzero(chan->whentohangup))	/* no if no hangup scheduled */
 		return 0;

Modified: team/group/newcdr/main/features.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/main/features.c?view=diff&rev=163487&r1=163486&r2=163487
==============================================================================
--- team/group/newcdr/main/features.c (original)
+++ team/group/newcdr/main/features.c Fri Dec 12 08:25:36 2008
@@ -2012,131 +2012,11 @@
 	struct ast_channel *monitor_chans[2];
 	struct ast_channel *active_channel;
 	int res = 0, ready = 0;
-
-	if ((chan = ast_request(type, format, caller, data, &cause))) {
-		ast_set_callerid(chan, cid_num, cid_name, cid_num);
-		ast_string_field_set(chan, language, language);
-		ast_channel_inherit_variables(caller, chan);	
-		pbx_builtin_setvar_helper(chan, "TRANSFERERNAME", caller->name);
-			
-		if (!ast_call(chan, data, timeout)) {
-			struct timeval started;
-			int x, len = 0;
-			char *disconnect_code = NULL, *dialed_code = NULL;
-
-			ast_indicate(caller, AST_CONTROL_RINGING);
-			/* support dialing of the featuremap disconnect code while performing an attended tranfer */
-			ast_rwlock_rdlock(&features_lock);
-			for (x = 0; x < FEATURES_COUNT; x++) {
-				if (strcasecmp(builtin_features[x].sname, "disconnect"))
-					continue;
-
-				disconnect_code = builtin_features[x].exten;
-				len = strlen(disconnect_code) + 1;
-				dialed_code = alloca(len);
-				memset(dialed_code, 0, len);
-				break;
-			}
-			ast_rwlock_unlock(&features_lock);
-			x = 0;
-			started = ast_tvnow();
-			to = timeout;
-
-			ast_poll_channel_add(caller, chan);
-
-			while (!((transferee && ast_check_hangup(transferee)) && (!igncallerstate && ast_check_hangup(caller))) && timeout && (chan->_state != AST_STATE_UP)) {
-				struct ast_frame *f = NULL;
-
-				monitor_chans[0] = caller;
-				monitor_chans[1] = chan;
-				active_channel = ast_waitfor_n(monitor_chans, 2, &to);
-
-				/* see if the timeout has been violated */
-				if(ast_tvdiff_ms(ast_tvnow(), started) > timeout) {
-					state = AST_CONTROL_UNHOLD;
-					ast_log(LOG_NOTICE, "We exceeded our AT-timeout\n");
-					break; /*doh! timeout*/
-				}
-
-				if (!active_channel)
-					continue;
-
-				if (chan && (chan == active_channel)){
-					f = ast_read(chan);
-					if (f == NULL) { /*doh! where'd he go?*/
-						state = AST_CONTROL_HANGUP;
-						res = 0;
-						break;
-					}
-					
-					if (f->frametype == AST_FRAME_CONTROL || f->frametype == AST_FRAME_DTMF || f->frametype == AST_FRAME_TEXT) {
-						if (f->subclass == AST_CONTROL_RINGING) {
-							state = f->subclass;
-							ast_verb(3, "%s is ringing\n", chan->name);
-							ast_indicate(caller, AST_CONTROL_RINGING);
-						} else if ((f->subclass == AST_CONTROL_BUSY) || (f->subclass == AST_CONTROL_CONGESTION)) {
-							state = f->subclass;
-							ast_verb(3, "%s is busy\n", chan->name);
-							ast_indicate(caller, AST_CONTROL_BUSY);
-							ast_frfree(f);
-							f = NULL;
-							break;
-						} else if (f->subclass == AST_CONTROL_ANSWER) {
-							/* This is what we are hoping for */
-							state = f->subclass;
-							ast_frfree(f);
-							f = NULL;
-							ready=1;
-							break;
-						} else if (f->subclass != -1) {
-							ast_log(LOG_NOTICE, "Don't know what to do about control frame: %d\n", f->subclass);
-						}
-						/* else who cares */
-					}
-
-				} else if (caller && (active_channel == caller)) {
-					f = ast_read(caller);
-					if (f == NULL) { /*doh! where'd he go?*/
-						if (!igncallerstate) {
-							if (ast_check_hangup(caller) && !ast_check_hangup(chan)) {
-								/* make this a blind transfer */
-								ready = 1;
-								break;
-							}
-							state = AST_CONTROL_HANGUP;
-							res = 0;
-							break;
-						}
-					} else {
-					
-						if (f->frametype == AST_FRAME_DTMF) {
-							dialed_code[x++] = f->subclass;
-							dialed_code[x] = '\0';
-							if (strlen(dialed_code) == len) {
-								x = 0;
-							} else if (x && strncmp(dialed_code, disconnect_code, x)) {
-								x = 0;
-								dialed_code[x] = '\0';
-							}
-							if (*dialed_code && !strcmp(dialed_code, disconnect_code)) {
-								/* Caller Canceled the call */
-								state = AST_CONTROL_UNHOLD;
-								ast_frfree(f);
-								f = NULL;
-								break;
-							}
-						}
-					}
-				}
-				if (f)
-					ast_frfree(f);
-			} /* end while */
-
-			ast_poll_channel_del(caller, chan);
-
-		} else
-			ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, (char *)data);
-	} else {
+	struct timeval started;
+	int x, len = 0;
+	char *disconnect_code = NULL, *dialed_code = NULL;
+
+	if (!(chan = ast_request(type, format, caller, data, &cause))) {
 		ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, (char *)data);
 		switch(cause) {
 		case AST_CAUSE_BUSY:
@@ -2146,14 +2026,136 @@
 			state = AST_CONTROL_CONGESTION;
 			break;
 		}
+		goto done;
+	}
+
+	ast_set_callerid(chan, cid_num, cid_name, cid_num);
+	ast_string_field_set(chan, language, language);
+	ast_channel_inherit_variables(caller, chan);	
+	pbx_builtin_setvar_helper(chan, "TRANSFERERNAME", caller->name);
+		
+	if (ast_call(chan, data, timeout)) {
+		ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, (char *)data);
+		goto done;
 	}
 	
+	ast_indicate(caller, AST_CONTROL_RINGING);
+	/* support dialing of the featuremap disconnect code while performing an attended tranfer */
+	ast_rwlock_rdlock(&features_lock);
+	for (x = 0; x < FEATURES_COUNT; x++) {
+		if (strcasecmp(builtin_features[x].sname, "disconnect"))
+			continue;
+
+		disconnect_code = builtin_features[x].exten;
+		len = strlen(disconnect_code) + 1;
+		dialed_code = alloca(len);
+		memset(dialed_code, 0, len);
+		break;
+	}
+	ast_rwlock_unlock(&features_lock);
+	x = 0;
+	started = ast_tvnow();
+	to = timeout;
+
+	ast_poll_channel_add(caller, chan);
+
+	while (!((transferee && ast_check_hangup(transferee)) && (!igncallerstate && ast_check_hangup(caller))) && timeout && (chan->_state != AST_STATE_UP)) {
+		struct ast_frame *f = NULL;
+
+		monitor_chans[0] = caller;
+		monitor_chans[1] = chan;
+		active_channel = ast_waitfor_n(monitor_chans, 2, &to);
+
+		/* see if the timeout has been violated */
+		if(ast_tvdiff_ms(ast_tvnow(), started) > timeout) {
+			state = AST_CONTROL_UNHOLD;
+			ast_log(LOG_NOTICE, "We exceeded our AT-timeout\n");
+			break; /*doh! timeout*/
+		}
+
+		if (!active_channel)
+			continue;
+
+		if (chan && (chan == active_channel)){
+			f = ast_read(chan);
+			if (f == NULL) { /*doh! where'd he go?*/
+				state = AST_CONTROL_HANGUP;
+				res = 0;
+				break;
+			}
+			
+			if (f->frametype == AST_FRAME_CONTROL || f->frametype == AST_FRAME_DTMF || f->frametype == AST_FRAME_TEXT) {
+				if (f->subclass == AST_CONTROL_RINGING) {
+					state = f->subclass;
+					ast_verb(3, "%s is ringing\n", chan->name);
+					ast_indicate(caller, AST_CONTROL_RINGING);
+				} else if ((f->subclass == AST_CONTROL_BUSY) || (f->subclass == AST_CONTROL_CONGESTION)) {
+					state = f->subclass;
+					ast_verb(3, "%s is busy\n", chan->name);
+					ast_indicate(caller, AST_CONTROL_BUSY);
+					ast_frfree(f);
+					f = NULL;
+					break;
+				} else if (f->subclass == AST_CONTROL_ANSWER) {
+					/* This is what we are hoping for */
+					state = f->subclass;
+					ast_frfree(f);
+					f = NULL;
+					ready=1;
+					break;
+				} else if (f->subclass != -1) {
+					ast_log(LOG_NOTICE, "Don't know what to do about control frame: %d\n", f->subclass);
+				}
+				/* else who cares */
+			}
+
+		} else if (caller && (active_channel == caller)) {
+			f = ast_read(caller);
+			if (f == NULL) { /*doh! where'd he go?*/
+				if (!igncallerstate) {
+					if (ast_check_hangup(caller) && !ast_check_hangup(chan)) {
+						/* make this a blind transfer */
+						ready = 1;
+						break;
+					}
+					state = AST_CONTROL_HANGUP;
+					res = 0;
+					break;
+				}
+			} else {
+			
+				if (f->frametype == AST_FRAME_DTMF) {
+					dialed_code[x++] = f->subclass;
+					dialed_code[x] = '\0';
+					if (strlen(dialed_code) == len) {
+						x = 0;
+					} else if (x && strncmp(dialed_code, disconnect_code, x)) {
+						x = 0;
+						dialed_code[x] = '\0';
+					}
+					if (*dialed_code && !strcmp(dialed_code, disconnect_code)) {
+						/* Caller Canceled the call */
+						state = AST_CONTROL_UNHOLD;
+						ast_frfree(f);
+						f = NULL;
+						break;
+					}
+				}
+			}
+		}
+		if (f)
+			ast_frfree(f);
+	} /* end while */
+
+	ast_poll_channel_del(caller, chan);
+		
+done:
 	ast_indicate(caller, -1);
 	if (chan && ready) {
 		if (chan->_state == AST_STATE_UP) 
 			state = AST_CONTROL_ANSWER;
 		res = 0;
-	} else if(chan) {
+	} else if (chan) {
 		res = -1;
 		ast_hangup(chan);
 		chan = NULL;

Modified: team/group/newcdr/pbx/pbx_dundi.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/pbx/pbx_dundi.c?view=diff&rev=163487&r1=163486&r2=163487
==============================================================================
--- team/group/newcdr/pbx/pbx_dundi.c (original)
+++ team/group/newcdr/pbx/pbx_dundi.c Fri Dec 12 08:25:36 2008
@@ -101,6 +101,7 @@
 static int netsocket = -1;
 static pthread_t netthreadid = AST_PTHREADT_NULL;
 static pthread_t precachethreadid = AST_PTHREADT_NULL;
+static pthread_t clearcachethreadid = AST_PTHREADT_NULL;
 static unsigned int tos = 0;
 static int dundidebug = 0;
 static int authdebug = 0;
@@ -2112,6 +2113,40 @@
 	return NULL;
 }
 
+static void *process_clearcache(void *ignore)
+{
+	struct ast_db_entry *db_entry, *db_tree;
+	int striplen = sizeof("/dundi/cache");
+	time_t now;
+	
+	while (!dundi_shutdown) {
+		pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
+
+		time(&now);
+
+		db_entry = db_tree = ast_db_gettree("dundi/cache", NULL);
+		for (; db_entry; db_entry = db_entry->next) {
+			time_t expiry;
+
+			if (!ast_get_time_t(db_entry->data, &expiry, 0, NULL)) {
+				if (expiry < now) {
+					ast_debug(1, "clearing expired DUNDI cache entry: %s\n", db_entry->key);
+					ast_db_del("dundi/cache", db_entry->key + striplen);
+				}
+			}
+		}
+		ast_db_freetree(db_tree);
+
+		pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+		pthread_testcancel();
+		sleep(60);
+		pthread_testcancel();
+	}
+	
+	clearcachethreadid = AST_PTHREADT_NULL;
+	return NULL;
+}
+
 static void *process_precache(void *ign)
 {
 	struct dundi_precache_queue *qe;
@@ -2153,6 +2188,7 @@
 {
 	ast_pthread_create_background(&netthreadid, NULL, network_thread, NULL);
 	ast_pthread_create_background(&precachethreadid, NULL, process_precache, NULL);
+	ast_pthread_create_background(&clearcachethreadid, NULL, process_clearcache, NULL);
 	return 0;
 }
 
@@ -4687,7 +4723,7 @@
 
 static int unload_module(void)
 {
-	pthread_t previous_netthreadid = netthreadid, previous_precachethreadid = precachethreadid;
+	pthread_t previous_netthreadid = netthreadid, previous_precachethreadid = precachethreadid, previous_clearcachethreadid = clearcachethreadid;
 	ast_module_user_hangup_all();
 
 	/* Stop all currently running threads */
@@ -4700,6 +4736,10 @@
 		pthread_kill(previous_precachethreadid, SIGURG);
 		pthread_join(previous_precachethreadid, NULL);
 	}
+ 	if (previous_clearcachethreadid != AST_PTHREADT_NULL) {
+ 		pthread_cancel(previous_clearcachethreadid);
+ 		pthread_join(previous_clearcachethreadid, NULL);
+ 	}
 
 	ast_cli_unregister_multiple(cli_dundi, ARRAY_LEN(cli_dundi));
 	ast_unregister_switch(&dundi_switch);

Modified: team/group/newcdr/res/res_timing_pthread.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/res/res_timing_pthread.c?view=diff&rev=163487&r1=163486&r2=163487
==============================================================================
--- team/group/newcdr/res/res_timing_pthread.c (original)
+++ team/group/newcdr/res/res_timing_pthread.c Fri Dec 12 08:25:36 2008
@@ -151,6 +151,23 @@
 	ao2_ref(timer, -1);
 }
 
+static void set_state(struct pthread_timer *timer)
+{
+	unsigned int rate = timer->rate;
+
+	if (rate) {
+		timer->state = TIMER_STATE_TICKING;
+		timer->interval = roundf(1000.0 / ((float) rate));
+		timer->start = ast_tvnow();
+	} else {
+		timer->state = TIMER_STATE_IDLE;
+		timer->interval = 0;
+		timer->start = ast_tv(0, 0);
+	}
+
+	timer->tick_count = 0;
+}
+
 static int pthread_timer_set_rate(int handle, unsigned int rate)
 {
 	struct pthread_timer *timer;
@@ -169,10 +186,10 @@
 
 	ao2_lock(timer);
 	timer->rate = rate;
-	timer->state = rate ? TIMER_STATE_TICKING : TIMER_STATE_IDLE;
-	timer->interval = rate ? roundf(1000.0 / ((float) rate)) : 0;
-	timer->start = rate ? ast_tvnow() : ast_tv(0, 0);
-	timer->tick_count = 0;
+	if (timer->state != TIMER_STATE_CONTINUOUS) {
+		set_state(timer);
+	}
+	
 	ao2_unlock(timer);
 
 	ao2_ref(timer, -1);
@@ -229,7 +246,7 @@
 	}
 
 	ao2_lock(timer);
-	timer->state = timer->rate ? TIMER_STATE_TICKING : TIMER_STATE_IDLE;
+	set_state(timer);
 	read_pipe(timer->pipe[PIPE_READ], 0, 1);
 	ao2_unlock(timer);
 




More information about the svn-commits mailing list