[asterisk-commits] jpeeler: trunk r241143 - in /trunk: channels/ include/asterisk/ main/ pbx/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 18 16:31:32 CST 2010


Author: jpeeler
Date: Mon Jan 18 16:31:25 2010
New Revision: 241143

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=241143
Log:
Extend max call limit duration from 24.8 days to 292+ million years.

If the limit was set past MAX_INT upon answering, the call was immediately
hung up due to overflow from the return of ast_tvdiff_ms (in ast_check_hangup).
The time calculation functions ast_tvdiff_sec and ast_tvdiff_ms have been
changed to return an int64_t to prevent overflow. Also the reporter suggested
adding a message indicating the reason for the call hanging up. Given that the
new limit is so much higher, the message (which would only really be useful in
the overflow scenario) has been made a debug message only.

(closes issue #16006)
Reported by: viraptor

Modified:
    trunk/channels/chan_dahdi.c
    trunk/channels/sig_analog.c
    trunk/include/asterisk/time.h
    trunk/main/channel.c
    trunk/main/enum.c
    trunk/main/features.c
    trunk/main/timing.c
    trunk/pbx/pbx_dundi.c

Modified: trunk/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_dahdi.c?view=diff&rev=241143&r1=241142&r2=241143
==============================================================================
--- trunk/channels/chan_dahdi.c (original)
+++ trunk/channels/chan_dahdi.c Mon Jan 18 16:31:25 2010
@@ -7791,7 +7791,7 @@
 			(p->polarity == POLARITY_REV) &&
 			((ast->_state == AST_STATE_UP) || (ast->_state == AST_STATE_RING)) ) {
 			/* Added log_debug information below to provide a better indication of what is going on */
-			ast_debug(1, "Polarity Reversal event occured - DEBUG 1: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
+			ast_debug(1, "Polarity Reversal event occured - DEBUG 1: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %" PRIi64 "\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
 
 			if (ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) > p->polarityonanswerdelay) {
 				ast_debug(1, "Polarity Reversal detected and now Hanging up on channel %d\n", p->channel);
@@ -7805,7 +7805,7 @@
 			ast_debug(1, "Ignoring Polarity switch to IDLE on channel %d, state %d\n", p->channel, ast->_state);
 		}
 		/* Added more log_debug information below to provide a better indication of what is going on */
-		ast_debug(1, "Polarity Reversal event occured - DEBUG 2: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
+		ast_debug(1, "Polarity Reversal event occured - DEBUG 2: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %" PRIi64 "\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
 		break;
 	default:
 		ast_debug(1, "Dunno what to do with event %d on channel %d\n", res, p->channel);

Modified: trunk/channels/sig_analog.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sig_analog.c?view=diff&rev=241143&r1=241142&r2=241143
==============================================================================
--- trunk/channels/sig_analog.c (original)
+++ trunk/channels/sig_analog.c Mon Jan 18 16:31:25 2010
@@ -3137,7 +3137,7 @@
 		}
 
 		/* Added more log_debug information below to provide a better indication of what is going on */
-		ast_debug(1, "Polarity Reversal event occured - DEBUG 2: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
+		ast_debug(1, "Polarity Reversal event occured - DEBUG 2: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %" PRIi64 "\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
 		break;
 	default:
 		ast_debug(1, "Dunno what to do with event %d on channel %d\n", res, p->channel);

Modified: trunk/include/asterisk/time.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/time.h?view=diff&rev=241143&r1=241142&r2=241143
==============================================================================
--- trunk/include/asterisk/time.h (original)
+++ trunk/include/asterisk/time.h Mon Jan 18 16:31:25 2010
@@ -43,9 +43,9 @@
  * \return the difference in seconds
  */
 AST_INLINE_API(
-int ast_tvdiff_sec(struct timeval end, struct timeval start),
+int64_t ast_tvdiff_sec(struct timeval end, struct timeval start),
 {
-	int result = end.tv_sec - start.tv_sec;
+	int64_t result = end.tv_sec - start.tv_sec;
 	if (result > 0 && end.tv_usec < start.tv_usec)
 		result--;
 	else if (result < 0 && end.tv_usec > start.tv_usec)
@@ -76,7 +76,7 @@
  * \return the difference in milliseconds
  */
 AST_INLINE_API(
-int ast_tvdiff_ms(struct timeval end, struct timeval start),
+int64_t ast_tvdiff_ms(struct timeval end, struct timeval start),
 {
 	/* the offset by 1,000,000 below is intentional...
 	   it avoids differences in the way that division

Modified: trunk/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/channel.c?view=diff&rev=241143&r1=241142&r2=241143
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Mon Jan 18 16:31:25 2010
@@ -479,6 +479,7 @@
 		return 0;
 	if (ast_tvdiff_ms(chan->whentohangup, ast_tvnow()) > 0) 	/* no if hangup time has not come yet. */
 		return 0;
+	ast_debug(4, "Hangup time has come: %" PRIi64 "\n", ast_tvdiff_ms(chan->whentohangup, ast_tvnow()));
 	chan->_softhangup |= AST_SOFTHANGUP_TIMEOUT;	/* record event */
 	return 1;
 }

Modified: trunk/main/enum.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/enum.c?view=diff&rev=241143&r1=241142&r2=241143
==============================================================================
--- trunk/main/enum.c (original)
+++ trunk/main/enum.c Mon Jan 18 16:31:25 2010
@@ -851,7 +851,7 @@
 	ret = ast_search_dns(context, tmp, C_IN, T_NAPTR, enum_callback);
 	time_end = ast_tvnow();
 
-	ast_verb(2, "ast_get_enum() profiling: %s, %s, %d ms\n", 
+	ast_verb(2, "ast_get_enum() profiling: %s, %s, %" PRIi64 " ms\n", 
 			(ret == 0) ? "OK" : "FAIL", tmp, ast_tvdiff_ms(time_end, time_start));
 
 	if (ret < 0) {

Modified: trunk/main/features.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/features.c?view=diff&rev=241143&r1=241142&r2=241143
==============================================================================
--- trunk/main/features.c (original)
+++ trunk/main/features.c Mon Jan 18 16:31:25 2010
@@ -4923,12 +4923,12 @@
 		config->timelimit = play_to_caller = play_to_callee =
 		config->play_warning = config->warning_freq = 0;
 	} else {
-		ast_verb(3, "Limit Data for this call:\n");
-		ast_verb(4, "timelimit      = %ld\n", config->timelimit);
-		ast_verb(4, "play_warning   = %ld\n", config->play_warning);
+		ast_verb(4, "Limit Data for this call:\n");
+		ast_verb(4, "timelimit      = %ld ms (%.3lf s)\n", config->timelimit, config->timelimit / 1000.0);
+		ast_verb(4, "play_warning   = %ld ms (%.3lf s)\n", config->play_warning, config->play_warning / 1000.0);
 		ast_verb(4, "play_to_caller = %s\n", play_to_caller ? "yes" : "no");
 		ast_verb(4, "play_to_callee = %s\n", play_to_callee ? "yes" : "no");
-		ast_verb(4, "warning_freq   = %ld\n", config->warning_freq);
+		ast_verb(4, "warning_freq   = %ld ms (%.3lf s)\n", config->warning_freq, config->warning_freq / 1000.0);
 		ast_verb(4, "start_sound    = %s\n", S_OR(config->start_sound, ""));
 		ast_verb(4, "warning_sound  = %s\n", config->warning_sound);
 		ast_verb(4, "end_sound      = %s\n", S_OR(config->end_sound, ""));

Modified: trunk/main/timing.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/timing.c?view=diff&rev=241143&r1=241142&r2=241143
==============================================================================
--- trunk/main/timing.c (original)
+++ trunk/main/timing.c Mon Jan 18 16:31:25 2010
@@ -270,7 +270,7 @@
 
 	ast_timer_close(timer);
 
-	ast_cli(a->fd, "It has been %d milliseconds, and we got %d timer ticks\n", 
+	ast_cli(a->fd, "It has been %" PRIi64 " milliseconds, and we got %d timer ticks\n", 
 		ast_tvdiff_ms(end, start), count);
 
 	return CLI_SUCCESS;

Modified: trunk/pbx/pbx_dundi.c
URL: http://svnview.digium.com/svn/asterisk/trunk/pbx/pbx_dundi.c?view=diff&rev=241143&r1=241142&r2=241143
==============================================================================
--- trunk/pbx/pbx_dundi.c (original)
+++ trunk/pbx/pbx_dundi.c Mon Jan 18 16:31:25 2010
@@ -2393,7 +2393,7 @@
 		ast_cli(a->fd, "%3d. %5d %s/%s (%s)\n", x + 1, dr[x].weight, dr[x].tech, dr[x].dest, dundi_flags2str(fs, sizeof(fs), dr[x].flags));
 		ast_cli(a->fd, "     from %s, expires in %d s\n", dr[x].eid_str, dr[x].expiration);
 	}
-	ast_cli(a->fd, "DUNDi lookup completed in %d ms\n", ast_tvdiff_ms(ast_tvnow(), start));
+	ast_cli(a->fd, "DUNDi lookup completed in %" PRIi64 " ms\n", ast_tvdiff_ms(ast_tvnow(), start));
 	return CLI_SUCCESS;
 }
 
@@ -2430,7 +2430,7 @@
 		ast_cli(a->fd, "DUNDi precache returned error.\n");
 	else if (!res)
 		ast_cli(a->fd, "DUNDi precache returned no error.\n");
-	ast_cli(a->fd, "DUNDi lookup completed in %d ms\n", ast_tvdiff_ms(ast_tvnow(), start));
+	ast_cli(a->fd, "DUNDi lookup completed in %" PRIi64 " ms\n", ast_tvdiff_ms(ast_tvnow(), start));
 	return CLI_SUCCESS;
 }
 




More information about the asterisk-commits mailing list