add separate reg timeout from retry sec

This commit is contained in:
Anthony Minessale 2010-11-03 10:58:32 -05:00
parent fc4d290cb7
commit e5b891eed1
3 changed files with 17 additions and 3 deletions

View File

@ -414,6 +414,7 @@ struct sofia_gateway {
time_t expires; time_t expires;
time_t retry; time_t retry;
time_t ping; time_t ping;
time_t reg_timeout;
int pinging; int pinging;
sofia_gateway_status_t status; sofia_gateway_status_t status;
uint32_t ping_freq; uint32_t ping_freq;
@ -422,6 +423,7 @@ struct sofia_gateway {
int ping_min; int ping_min;
uint8_t flags[REG_FLAG_MAX]; uint8_t flags[REG_FLAG_MAX];
int32_t retry_seconds; int32_t retry_seconds;
int32_t reg_timeout_seconds;
int32_t failure_status; int32_t failure_status;
reg_state_t state; reg_state_t state;
switch_memory_pool_t *pool; switch_memory_pool_t *pool;

View File

@ -1874,6 +1874,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
*context = profile->context, *context = profile->context,
*expire_seconds = "3600", *expire_seconds = "3600",
*retry_seconds = "30", *retry_seconds = "30",
*timeout_seconds = "60",
*from_user = "", *from_domain = NULL, *outbound_proxy = NULL, *register_proxy = NULL, *contact_host = NULL, *from_user = "", *from_domain = NULL, *outbound_proxy = NULL, *register_proxy = NULL, *contact_host = NULL,
*contact_params = NULL, *params = NULL, *register_transport = NULL; *contact_params = NULL, *params = NULL, *register_transport = NULL;
@ -1982,6 +1983,8 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
expire_seconds = val; expire_seconds = val;
} else if (!strcmp(var, "retry-seconds")) { } else if (!strcmp(var, "retry-seconds")) {
retry_seconds = val; retry_seconds = val;
} else if (!strcmp(var, "timeout-seconds")) {
timeout_seconds = val;
} else if (!strcmp(var, "retry_seconds")) { // support typo for back compat } else if (!strcmp(var, "retry_seconds")) { // support typo for back compat
retry_seconds = val; retry_seconds = val;
} else if (!strcmp(var, "from-user")) { } else if (!strcmp(var, "from-user")) {
@ -2081,13 +2084,22 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
} }
gateway->retry_seconds = atoi(retry_seconds); gateway->retry_seconds = atoi(retry_seconds);
if (gateway->retry_seconds < 5) { 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", 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); gateway->retry_seconds, name);
gateway->retry_seconds = 30; gateway->retry_seconds = 30;
} }
gateway->reg_timeout_seconds = atoi(timeout_seconds);
if (gateway->retry_seconds < 5) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid timeout-seconds of %d on gateway %s, using the value of 60 instead.\n",
gateway->reg_timeout_seconds, name);
gateway->reg_timeout_seconds = 30;
}
gateway->register_scheme = switch_core_strdup(gateway->pool, scheme); gateway->register_scheme = switch_core_strdup(gateway->pool, scheme);
gateway->register_context = switch_core_strdup(gateway->pool, context); gateway->register_context = switch_core_strdup(gateway->pool, context);
gateway->register_realm = switch_core_strdup(gateway->pool, realm); gateway->register_realm = switch_core_strdup(gateway->pool, realm);

View File

@ -363,7 +363,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
NUTAG_REGISTRAR(gateway_ptr->register_proxy), NUTAG_REGISTRAR(gateway_ptr->register_proxy),
NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL()); NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL());
} }
gateway_ptr->retry = now + gateway_ptr->retry_seconds; gateway_ptr->reg_timeout = now + gateway_ptr->reg_timeout_seconds;
gateway_ptr->state = REG_STATE_TRYING; gateway_ptr->state = REG_STATE_TRYING;
switch_safe_free(user_via); switch_safe_free(user_via);
user_via = NULL; user_via = NULL;
@ -408,7 +408,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
} }
break; break;
case REG_STATE_TRYING: case REG_STATE_TRYING:
if (!gateway_ptr->retry || now >= gateway_ptr->retry) { if (now >= gateway_ptr->reg_timeout) {
gateway_ptr->state = REG_STATE_TIMEOUT; gateway_ptr->state = REG_STATE_TIMEOUT;
} }
break; break;