Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (15762 => 15763)
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h 2009-12-02 20:28:49 UTC (rev 15762)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h 2009-12-02 20:47:46 UTC (rev 15763)
@@ -383,6 +383,7 @@
int ping_min;
uint8_t flags[REG_FLAG_MAX];
int32_t retry_seconds;
+ int32_t failure_status;
reg_state_t state;
switch_memory_pool_t *pool;
int deleted;
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (15762 => 15763)
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c 2009-12-02 20:28:49 UTC (rev 15762)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c 2009-12-02 20:47:46 UTC (rev 15763)
@@ -323,7 +323,8 @@
break;
case REG_STATE_UNREGED:
gateway_ptr->status = SOFIA_GATEWAY_DOWN;
-
+ gateway_ptr->retry = 0;
+
if (!gateway_ptr->nh) sofia_reg_new_handle(gateway_ptr, now ? 1 : 0);
if (sofia_glue_check_nat(gateway_ptr->profile, gateway_ptr->register_proxy)) {
@@ -361,11 +362,24 @@
break;
case REG_STATE_FAILED:
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s Failed Registration, setting retry to %d seconds.\n",
- gateway_ptr->name, gateway_ptr->retry_seconds * (gateway_ptr->failures + 1));
- gateway_ptr->retry = now + (gateway_ptr->retry_seconds * (gateway_ptr->failures + 1));
- gateway_ptr->status = SOFIA_GATEWAY_DOWN;
- gateway_ptr->state = REG_STATE_FAIL_WAIT;
+ {
+ int sec;
+
+ if (gateway_ptr->failure_status == 503) {
+ sec = now + gateway_ptr->retry_seconds;
+ } else{
+ sec = gateway_ptr->retry_seconds * (gateway_ptr->failures + 1);
+ }
+
+ gateway_ptr->retry = sec;
+ gateway_ptr->status = SOFIA_GATEWAY_DOWN;
+ gateway_ptr->state = REG_STATE_FAIL_WAIT;
+ gateway_ptr->failure_status = 0;
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s Failed Registration, setting retry to %d seconds.\n",
+ gateway_ptr->name, sec);
+
+ }
break;
case REG_STATE_FAIL_WAIT:
if (!gateway_ptr->retry || now >= gateway_ptr->retry) {
@@ -1440,6 +1454,7 @@
break;
default:
sofia_private->gateway->state = REG_STATE_FAILED;
+ sofia_private->gateway->failure_status = status;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Registration Failed with status %s [%d]. failure #%d\n",
sofia_private->gateway->name, switch_str_nil(phrase), status, ++sofia_private->gateway->failures);
break;