add 908-retry-seconds gateway param to set reg retry time when getting a 908 for backup interfaces to connect quickly

This commit is contained in:
Michael Jerris 2014-10-09 14:43:16 -04:00
parent b578aa7c9e
commit 855cc4b4e0
3 changed files with 11 additions and 1 deletions

View File

@ -505,6 +505,7 @@ struct sofia_gateway {
switch_bool_t ping_monitoring;
uint8_t flags[REG_FLAG_MAX];
int32_t retry_seconds;
int32_t fail_908_retry_seconds;
int32_t reg_timeout_seconds;
int32_t failure_status;
reg_state_t state;

View File

@ -3320,6 +3320,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
*context = profile->context,
*expire_seconds = "3600",
*retry_seconds = "30",
*fail_908_retry_seconds = NULL,
*timeout_seconds = "60",
*from_user = "", *from_domain = NULL, *outbound_proxy = NULL, *register_proxy = NULL, *contact_host = NULL,
*contact_params = "", *params = NULL, *register_transport = NULL,
@ -3434,6 +3435,8 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
context = val;
} else if (!strcmp(var, "expire-seconds")) {
expire_seconds = val;
} else if (!strcmp(var, "908-retry-seconds")) {
fail_908_retry_seconds = val;
} else if (!strcmp(var, "retry-seconds")) {
retry_seconds = val;
} else if (!strcmp(var, "timeout-seconds")) {
@ -3547,6 +3550,10 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
gateway->retry_seconds = atoi(retry_seconds);
if (fail_908_retry_seconds) {
gateway->fail_908_retry_seconds = atoi(fail_908_retry_seconds);
}
if (gateway->retry_seconds < 5) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid retry-seconds of %d on gateway %s, using the value of 30 instead.\n",
gateway->retry_seconds, name);

View File

@ -493,7 +493,9 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
{
int sec;
if (gateway_ptr->failure_status == 503 || gateway_ptr->failure_status == 908 || gateway_ptr->failures < 1) {
if (gateway_ptr->fail_908_retry_seconds && gateway_ptr->failure_status == 908) {
sec = gateway_ptr->fail_908_retry_seconds;
} else if (gateway_ptr->failure_status == 503 || gateway_ptr->failure_status == 908 || gateway_ptr->failures < 1) {
sec = gateway_ptr->retry_seconds;
} else {
sec = gateway_ptr->retry_seconds * gateway_ptr->failures;