]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add registration-thread-frequency param
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 9 Jan 2012 23:17:03 +0000 (17:17 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 9 Jan 2012 23:17:03 +0000 (17:17 -0600)
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_reg.c

index 33a9538fde54df216204956e2907baa36af2c388..32f0af7441bd43f7375e5c01a22bb42c3d102c3c 100644 (file)
@@ -647,6 +647,7 @@ struct sofia_profile {
        su_strlst_t *tls_verify_in_subjects;
        uint32_t sip_force_expires;
        uint32_t sip_expires_max_deviation;
+       int ireg_seconds;
 };
 
 struct private_object {
index b1e65d0d36f8b3de428e367209b41cbec44a3da1..12d3cf1ba4f9d90f0152fdf3c6132441e46e18bb 100644 (file)
@@ -1570,7 +1570,7 @@ void watchdog_triggered_abort(void) {
 void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread, void *obj)
 {
        sofia_profile_t *profile = (sofia_profile_t *) obj;
-       uint32_t ireg_loops = IREG_SECONDS;                                     /* Number of loop iterations done when we haven't checked for registrations */
+       uint32_t ireg_loops = profile->ireg_seconds;                                    /* Number of loop iterations done when we haven't checked for registrations */
        uint32_t gateway_loops = GATEWAY_SECONDS;                       /* Number of loop iterations done when we haven't checked for gateways */
        void *pop = NULL;                                       /* queue_pop placeholder */
        switch_size_t sql_len = 1024 * 32;      /* length of sqlbuf */
@@ -2972,6 +2972,11 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
                                                sofia_glue_parse_rtp_bugs(&profile->auto_rtp_bugs, val);
                                        } else if (!strcasecmp(var, "manual-rtp-bugs")) {
                                                sofia_glue_parse_rtp_bugs(&profile->manual_rtp_bugs, val);
+                                       } else if (!strcasecmp(var, "registration-thread-frequency")) {
+                                               profile->ireg_seconds = atoi(val);
+                                               if (profile->ireg_seconds < 0) {
+                                                       profile->ireg_seconds = IREG_SECONDS;
+                                               }
                                        } else if (!strcasecmp(var, "user-agent-string")) {
                                                profile->user_agent = switch_core_strdup(profile->pool, val);
                                        } else if (!strcasecmp(var, "auto-restart")) {
@@ -3693,6 +3698,8 @@ switch_status_t config_sofia(int reload, char *profile_name)
                                sofia_set_pflag(profile, PFLAG_CID_IN_1XX);
                                profile->ndlb |= PFLAG_NDLB_ALLOW_NONDUP_SDP;
                                profile->te = 101;
+                               profile->ireg_seconds = IREG_SECONDS;
+
 
                                 profile->tls_verify_policy = TPTLS_VERIFY_NONE;
                                 /* lib default */
@@ -3732,6 +3739,11 @@ switch_status_t config_sofia(int reload, char *profile_name)
                                                 } else {
                                                         sofia_clear_pflag(profile, PFLAG_FORWARD_MWI_NOTIFY);
                                                 }
+                                       } else if (!strcasecmp(var, "registration-thread-frequency")) {
+                                               profile->ireg_seconds = atoi(val);
+                                               if (profile->ireg_seconds < 0) {
+                                                       profile->ireg_seconds = IREG_SECONDS;
+                                               }
                                        } else if (!strcasecmp(var, "user-agent-string")) {
                                                profile->user_agent = switch_core_strdup(profile->pool, val);
                                        } else if (!strcasecmp(var, "auto-restart")) {
index 73a43414ab74987495eb97a1e54c09262fbd39f1..36c7204251aabeafbae344b0ca86956eb2e647fe 100644 (file)
@@ -373,10 +373,14 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
 
                        gateway_ptr->failures = 0;
 
-                       if (gateway_ptr->freq > 60) {
+                       if (gateway_ptr->freq >= 60) {
                                gateway_ptr->expires = now + (gateway_ptr->freq - 15);
                        } else {
-                               gateway_ptr->expires = now + (gateway_ptr->freq - 2);
+                               if (gateway_ptr->freq < 30 && gateway_ptr->freq >= 5) {
+                                       gateway_ptr->expires = now + (gateway_ptr->freq - 5);
+                               } else {
+                                       gateway_ptr->expires = now + (gateway_ptr->freq);
+                               }
                        }
 
                        gateway_ptr->state = REG_STATE_REGED;