From f095ef0645dc26834547ad46ff1eb53e182fed24 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Mon, 14 Apr 2008 15:55:37 +0000 Subject: [PATCH] try to avoid internal routing loops. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8103 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/switch_ivr.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 747f99b94a..5274c46202 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -934,6 +934,20 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_ switch_core_session_t *other_session; switch_channel_t *other_channel = NULL; const char *uuid = NULL; + const char *max_forwards; + const char *forwardvar = switch_channel_get_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE); + int forwardval = 70; + + if (!switch_strlen_zero(forwardvar)) { + forwardval = atoi(forwardvar) - 1; + } + if (forwardval <= 0) { + switch_channel_hangup(channel, SWITCH_CAUSE_EXCHANGE_ROUTING_ERROR); + return SWITCH_STATUS_FALSE; + } + + max_forwards = switch_core_session_sprintf(session, "%d", forwardval); + switch_channel_set_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE, max_forwards); switch_core_session_reset(session, SWITCH_TRUE); switch_channel_clear_flag(channel, CF_ORIGINATING);