From 5b7e20133ae3cbc2e8afa1f8ddef675629007929 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 9 Jan 2012 17:17:03 -0600 Subject: [PATCH] add registration-thread-frequency param --- src/mod/endpoints/mod_sofia/mod_sofia.h | 1 + src/mod/endpoints/mod_sofia/sofia.c | 14 +++++++++++++- src/mod/endpoints/mod_sofia/sofia_reg.c | 8 ++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 33a9538fde..32f0af7441 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -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 { diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index b1e65d0d36..12d3cf1ba4 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -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")) { diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 73a43414ab..36c7204251 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -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;