reg expire tweak
This commit is contained in:
parent
5b7e20133a
commit
61917bb58e
|
@ -278,6 +278,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
|
||||||
{
|
{
|
||||||
sofia_gateway_t *check, *gateway_ptr, *last = NULL;
|
sofia_gateway_t *check, *gateway_ptr, *last = NULL;
|
||||||
switch_event_t *event;
|
switch_event_t *event;
|
||||||
|
int delta = 0;
|
||||||
|
|
||||||
switch_mutex_lock(profile->gw_mutex);
|
switch_mutex_lock(profile->gw_mutex);
|
||||||
for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) {
|
for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) {
|
||||||
|
@ -373,16 +374,18 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
|
||||||
|
|
||||||
gateway_ptr->failures = 0;
|
gateway_ptr->failures = 0;
|
||||||
|
|
||||||
if (gateway_ptr->freq >= 60) {
|
if (gateway_ptr->freq > 30) {
|
||||||
gateway_ptr->expires = now + (gateway_ptr->freq - 15);
|
delta = (gateway_ptr->freq - 15);
|
||||||
} else {
|
} else {
|
||||||
if (gateway_ptr->freq < 30 && gateway_ptr->freq >= 5) {
|
delta = (gateway_ptr->freq / 2);
|
||||||
gateway_ptr->expires = now + (gateway_ptr->freq - 5);
|
|
||||||
} else {
|
|
||||||
gateway_ptr->expires = now + (gateway_ptr->freq);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (delta < 1) {
|
||||||
|
delta = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
gateway_ptr->expires = now + delta;
|
||||||
|
|
||||||
gateway_ptr->state = REG_STATE_REGED;
|
gateway_ptr->state = REG_STATE_REGED;
|
||||||
gateway_ptr->status = SOFIA_GATEWAY_UP;
|
gateway_ptr->status = SOFIA_GATEWAY_UP;
|
||||||
break;
|
break;
|
||||||
|
@ -390,9 +393,9 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
|
||||||
case REG_STATE_UNREGISTER:
|
case REG_STATE_UNREGISTER:
|
||||||
sofia_reg_kill_reg(gateway_ptr);
|
sofia_reg_kill_reg(gateway_ptr);
|
||||||
gateway_ptr->state = REG_STATE_NOREG;
|
gateway_ptr->state = REG_STATE_NOREG;
|
||||||
|
gateway_ptr->status = SOFIA_GATEWAY_DOWN;
|
||||||
break;
|
break;
|
||||||
case REG_STATE_UNREGED:
|
case REG_STATE_UNREGED:
|
||||||
gateway_ptr->status = SOFIA_GATEWAY_DOWN;
|
|
||||||
gateway_ptr->retry = 0;
|
gateway_ptr->retry = 0;
|
||||||
|
|
||||||
if (!gateway_ptr->nh) {
|
if (!gateway_ptr->nh) {
|
||||||
|
@ -423,6 +426,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
|
||||||
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->retry = now + gateway_ptr->retry_seconds;
|
||||||
} else {
|
} else {
|
||||||
|
gateway_ptr->status = SOFIA_GATEWAY_DOWN;
|
||||||
nua_unregister(gateway_ptr->nh,
|
nua_unregister(gateway_ptr->nh,
|
||||||
NUTAG_URL(gateway_ptr->register_url),
|
NUTAG_URL(gateway_ptr->register_url),
|
||||||
TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
|
TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
|
||||||
|
|
Loading…
Reference in New Issue