Modify sofia profile to attempt to bind to the interface up to 3 tries with a 5 second wait between attempts.
Add new profile params bind-attempts and bind-attempt-interval to modify default behavior. --NEEDSDOCS
This commit is contained in:
parent
7ce2009fad
commit
956da6d689
|
@ -5326,7 +5326,6 @@ static void general_event_handler(switch_event_t *event)
|
|||
}
|
||||
}
|
||||
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
|
||||
sofia_glue_restart_all_profiles();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -716,6 +716,8 @@ struct sofia_profile {
|
|||
int tcp_pingpong;
|
||||
int tcp_ping2pong;
|
||||
ka_type_t keepalive;
|
||||
int bind_attempts;
|
||||
int bind_attempt_interval;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -2666,7 +2666,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
|
|||
int use_timer = !sofia_test_pflag(profile, PFLAG_DISABLE_TIMER);
|
||||
int use_rfc_5626 = sofia_test_pflag(profile, PFLAG_ENABLE_RFC5626);
|
||||
const char *supported = NULL;
|
||||
int sanity;
|
||||
int sanity, attempts = 0;
|
||||
switch_thread_t *worker_thread;
|
||||
switch_status_t st;
|
||||
char qname [128] = "";
|
||||
|
@ -2707,6 +2707,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
|
|||
profile->tls_verify_in_subjects = su_strlst_dup_split((su_home_t *)profile->nua, profile->tls_verify_in_subjects_str, "|");
|
||||
}
|
||||
|
||||
do {
|
||||
profile->nua = nua_create(profile->s_root, /* Event loop */
|
||||
sofia_event_callback, /* Callback for processing events */
|
||||
profile, /* Additional data to pass to callback */
|
||||
|
@ -2774,6 +2775,16 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
|
|||
TPTAG_REUSE(0)),
|
||||
TAG_END()); /* Last tag should always finish the sequence */
|
||||
|
||||
if (!profile->nua) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Creating SIP UA for profile: %s (%s) ATTEMPT %d (RETRY IN %d SEC)\n",
|
||||
profile->name, profile->bindurl, attempts + 1, profile->bind_attempt_interval);
|
||||
if (attempts < profile->bind_attempts) {
|
||||
switch_yield(1000000 * profile->bind_attempt_interval);
|
||||
}
|
||||
}
|
||||
|
||||
} while (!profile->nua && attempts++ < profile->bind_attempts);
|
||||
|
||||
if (!profile->nua) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Creating SIP UA for profile: %s (%s)\n"
|
||||
"The likely causes for this are:\n" "1) Another application is already listening on the specified address.\n"
|
||||
|
@ -4000,7 +4011,8 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
|
|||
profile->te = 101;
|
||||
profile->ireg_seconds = IREG_SECONDS;
|
||||
profile->paid_type = PAID_DEFAULT;
|
||||
|
||||
profile->bind_attempts = 2;
|
||||
profile->bind_attempt_interval = 5;
|
||||
|
||||
profile->tls_verify_policy = TPTLS_VERIFY_NONE;
|
||||
/* lib default */
|
||||
|
@ -4044,6 +4056,18 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
|
|||
profile->keepalive = KA_MESSAGE;
|
||||
}
|
||||
}
|
||||
} else if (!strcasecmp(var, "bind-attempts") && val) {
|
||||
int ba = atoi(val) - 1;
|
||||
|
||||
if (ba >= 0) {
|
||||
profile->bind_attempts = ba;
|
||||
}
|
||||
} else if (!strcasecmp(var, "bind-attempt-interval") && val) {
|
||||
int bai = atoi(val);
|
||||
|
||||
if (bai >= 0) {
|
||||
profile->bind_attempt_interval = bai;
|
||||
}
|
||||
} else if (!strcasecmp(var, "shutdown-on-fail")) {
|
||||
profile->shutdown_type = switch_core_strdup(profile->pool, val);
|
||||
} else if (!strcasecmp(var, "sip-trace") && switch_true(val)) {
|
||||
|
|
Loading…
Reference in New Issue