From 371a3d41855ad629f6e1c6b5ff271bd198140933 Mon Sep 17 00:00:00 2001 From: Mark Spencer Date: Thu, 20 Mar 2003 05:20:19 +0000 Subject: [PATCH] Fix channel restarting (first try) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@659 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_zap.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/channels/chan_zap.c b/channels/chan_zap.c index 0e50baa0e5..ee1083950a 100755 --- a/channels/chan_zap.c +++ b/channels/chan_zap.c @@ -5199,6 +5199,24 @@ static void zt_pri_error(char *s) ast_log(LOG_WARNING, "PRI: %s", s); } +static int pri_check_restart(struct zt_pri *pri) +{ + do { + pri->resetchannel++; + } while((pri->resetchannel <= pri->channels) && + (!pri->pvt[pri->resetchannel] || + pri->pvt[pri->resetchannel]->call || + pri->pvt[pri->resetchannel]->resetting)); + if (pri->resetchannel <= pri->channels) { + /* Mark the channel as resetting and restart it */ + pri->pvt[pri->resetchannel]->resetting = 1; + pri_reset(pri->pri, pri->resetchannel); + } else { + pri->resetting = 0; + } + return 0; +} + static void *pri_dchannel(void *vpri) { struct zt_pri *pri = vpri; @@ -5246,23 +5264,8 @@ static void *pri_dchannel(void *vpri) time(&t); ast_pthread_mutex_lock(&pri->lock); if (pri->resetting && pri->up) { - /* Look for a resetable channel and go */ - if ((t - pri->lastreset) > 0) { - pri->lastreset = t; - do { - pri->resetchannel++; - } while((pri->resetchannel <= pri->channels) && - (!pri->pvt[pri->resetchannel] || - pri->pvt[pri->resetchannel]->call || - pri->pvt[pri->resetchannel]->resetting)); - if (pri->resetchannel <= pri->channels) { - /* Mark the channel as resetting and restart it */ - pri->pvt[pri->resetchannel]->resetting = 1; - pri_reset(pri->pri, pri->resetchannel); - } else { - pri->resetting = 0; - } - } + if (!pri->resetchannel) + pri_check_reset(pri); } else { if ((t - pri->lastreset) >= RESET_INTERVAL) { pri->resetting = 1; @@ -5652,6 +5655,8 @@ static void *pri_dchannel(void *vpri) if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "B-channel %d successfully restarted on span %d\n", chan, pri->span); ast_pthread_mutex_unlock(&pri->pvt[chan]->lock); + if (pri->resetting) + pri_check_restart(pri); break; } }