From c6452cc8daf43619362a3fb3e230bcc2c71b68b6 Mon Sep 17 00:00:00 2001 From: Dmitry Ukolov Date: Thu, 6 Oct 2022 13:15:41 +0400 Subject: [PATCH] [mod_sofia] Add db-spin-up-wait-ms profile parameter. --- conf/vanilla/sip_profiles/internal.xml | 3 +++ src/mod/endpoints/mod_sofia/mod_sofia.h | 1 + src/mod/endpoints/mod_sofia/sofia.c | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/conf/vanilla/sip_profiles/internal.xml b/conf/vanilla/sip_profiles/internal.xml index 749e4b0687..5e38cfac1f 100644 --- a/conf/vanilla/sip_profiles/internal.xml +++ b/conf/vanilla/sip_profiles/internal.xml @@ -239,6 +239,9 @@ + + + diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 9c4da13a67..34ca3d66e4 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -727,6 +727,7 @@ struct sofia_profile { uint32_t max_recv_requests_per_second; uint32_t rtp_timeout_sec; uint32_t rtp_hold_timeout_sec; + uint32_t db_spin_up_wait_ms; char *odbc_dsn; char *pre_trans_execute; char *post_trans_execute; diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 9022039eb3..dc52535e06 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -4650,6 +4650,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) profile->tls_version |= SOFIA_TLS_VERSION_TLSv1_2; profile->tls_version |= SOFIA_TLS_VERSION_TLSv1_3; profile->tls_timeout = 300; + profile->db_spin_up_wait_ms = 1000; profile->mflags = MFLAG_REFER | MFLAG_REGISTER; profile->server_rport_level = 1; profile->client_rport_level = 1; @@ -4788,6 +4789,8 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) } } else if (!strcasecmp(var, "odbc-dsn") && !zstr(val)) { profile->odbc_dsn = switch_core_strdup(profile->pool, val); + } else if (!strcasecmp(var, "db-spin-up-wait-ms") && !zstr(val)) { + profile->db_spin_up_wait_ms = atoi(val); } else if (!strcasecmp(var, "db-pre-trans-execute") && !zstr(val)) { profile->pre_trans_execute = switch_core_strdup(profile->pool, val); } else if (!strcasecmp(var, "db-post-trans-execute") && !zstr(val)) { @@ -6351,7 +6354,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) launch_sofia_profile_thread(profile); if (profile->odbc_dsn) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Connecting ODBC Profile %s [%s]\n", profile->name, url); - switch_yield(1000000); + switch_yield(profile->db_spin_up_wait_ms * 1000); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Started Profile %s [%s]\n", profile->name, url); }