]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add separate reg timeout from retry sec
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 3 Nov 2010 15:58:32 +0000 (10:58 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 3 Nov 2010 15:58:32 +0000 (10:58 -0500)
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_reg.c

index 6a9e4ce620bdf81b7bf57464d230da49d5b9c81e..6978e34ffc40f1ea49b29c7bbca5685d7bb614ac 100644 (file)
@@ -414,6 +414,7 @@ struct sofia_gateway {
        time_t expires;
        time_t retry;
        time_t ping;
+       time_t reg_timeout;
        int pinging;
        sofia_gateway_status_t status;
        uint32_t ping_freq;
@@ -422,6 +423,7 @@ struct sofia_gateway {
        int ping_min;
        uint8_t flags[REG_FLAG_MAX];
        int32_t retry_seconds;
+       int32_t reg_timeout_seconds;
        int32_t failure_status;
        reg_state_t state;
        switch_memory_pool_t *pool;
index ac1251daa9e6876e852e12aefe0a99f80a7608be..c29c35185f54e03f3520cdb014a846536d34e90f 100644 (file)
@@ -1874,6 +1874,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
                                *context = profile->context,
                                *expire_seconds = "3600",
                                *retry_seconds = "30",
+                               *timeout_seconds = "60",
                                *from_user = "", *from_domain = NULL, *outbound_proxy = NULL, *register_proxy = NULL, *contact_host = 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;
                                } else if (!strcmp(var, "retry-seconds")) {
                                        retry_seconds = val;
+                               } else if (!strcmp(var, "timeout-seconds")) {
+                                       timeout_seconds = val;
                                } else if (!strcmp(var, "retry_seconds")) {     // support typo for back compat
                                        retry_seconds = val;
                                } 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);
-
+                       
                        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);
                                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_context = switch_core_strdup(gateway->pool, context);
                        gateway->register_realm = switch_core_strdup(gateway->pool, realm);
index 2614bd6e15e6e6e7e2436e41fd577218eae69f40..67641ae616e6d384f9244891bf073ecabe280cc2 100644 (file)
@@ -363,7 +363,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
                                                           NUTAG_REGISTRAR(gateway_ptr->register_proxy),
                                                           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;
                        switch_safe_free(user_via);
                        user_via = NULL;
@@ -408,7 +408,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
                        }
                        break;
                case REG_STATE_TRYING:
-                       if (!gateway_ptr->retry || now >= gateway_ptr->retry) {
+                       if (now >= gateway_ptr->reg_timeout) {
                                gateway_ptr->state = REG_STATE_TIMEOUT;
                        }
                        break;