From aa25b367d65cf5016d7e1c6e8ebcf801e79f556c Mon Sep 17 00:00:00 2001
From: Mark Spencer <markster@digium.com>
Date: Wed, 23 Mar 2005 21:12:01 +0000
Subject: [PATCH] Allow resetinterval to be "never"

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5236 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 channels/chan_zap.c        | 14 +++++++++-----
 configs/zapata.conf.sample |  1 +
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index cf8527096c..c16d3b2ced 100755
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -7525,7 +7525,7 @@ static void *pri_dchannel(void *vpri)
 		numdchans = i;
 		time(&t);
 		ast_mutex_lock(&pri->lock);
-		if (pri->switchtype != PRI_SWITCH_GR303_TMC) {
+		if (pri->switchtype != PRI_SWITCH_GR303_TMC && (pri->resetinterval > 0)) {
 			if (pri->resetting && pri_is_up(pri)) {
 				if (pri->resetpos < 0)
 					pri_check_restart(pri);
@@ -7703,8 +7703,10 @@ static void *pri_dchannel(void *vpri)
 				time(&pri->lastreset);
 
 				/* Restart in 5 seconds */
-				pri->lastreset -= pri->resetinterval;
-				pri->lastreset += 5;
+				if (pri->resetinterval > -1) {
+					pri->lastreset -= pri->resetinterval;
+					pri->lastreset += 5;
+				}
 				pri->resetting = 0;
 				/* Take the channels from inalarm condition */
 				for (i=0; i<pri->numchans; i++)
@@ -9942,10 +9944,12 @@ static int setup_zap(int reload)
 			} else if (!strcasecmp(v->name, "unknownprefix")) {
 				strncpy(unknownprefix, v->value, sizeof(unknownprefix)-1);
 			} else if (!strcasecmp(v->name, "resetinterval")) {
-				if( atoi(v->value) >= 60 )
+				if (!strcasecmp(v->value, "never"))
+					resetinterval = -1;
+				else if( atoi(v->value) >= 60 )
 					resetinterval = atoi(v->value);
 				else
-					ast_log(LOG_WARNING, "'%s' is not a valid reset interval, should be >= 60 seconds at line %d\n",
+					ast_log(LOG_WARNING, "'%s' is not a valid reset interval, should be >= 60 seconds or 'never' at line %d\n",
 						v->value, v->lineno);
 			} else if (!strcasecmp(v->name, "minunused")) {
 				minunused = atoi(v->value);
diff --git a/configs/zapata.conf.sample b/configs/zapata.conf.sample
index 1a31c02814..5ddf6e2225 100755
--- a/configs/zapata.conf.sample
+++ b/configs/zapata.conf.sample
@@ -104,6 +104,7 @@ switchtype=national
 ; PRI resetinterval: sets the time in seconds between restart of unused channels, defaults to 3600
 ; minimum 60 seconds
 ; some PBXs don't like channel restarts. so set the interval to a very long interval e.g. 100000000
+; or 'never' to disable *entirely*.
 ;
 ;resetinterval = 3600 
 ;
-- 
GitLab