]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_sofia] Add db-spin-up-wait-ms profile parameter.
authorDmitry Ukolov <udmitry@mail.ru>
Thu, 6 Oct 2022 09:15:41 +0000 (13:15 +0400)
committerGitHub <noreply@github.com>
Thu, 6 Oct 2022 09:15:41 +0000 (12:15 +0300)
conf/vanilla/sip_profiles/internal.xml
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c

index 749e4b06879d864b8493da4530d44eb98da61088..5e38cfac1f129adda3ef910c34ed93eca6b8bf64 100644 (file)
     <!-- Or, if you have PGSQL support, you can use that -->
     <!--<param name="odbc-dsn" value="pgsql://hostaddr=127.0.0.1 dbname=freeswitch user=freeswitch password='' options='-c client_min_messages=NOTICE' application_name='freeswitch'" />-->
 
+    <!-- By default each profile will give the database 1000 ms to spin-up on load -->
+    <!--<param name="db-spin-up-wait-ms" value="1000" />-->
+
     <!--Uncomment to set all inbound calls to no media mode-->
     <!--<param name="inbound-bypass-media" value="true"/>-->
 
index 9c4da13a6738b38c9e211ff4ce142c2d2d4f391b..34ca3d66e476429b05c607595a70644193197554 100644 (file)
@@ -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;
index 9022039eb37c98a2aade5196579911791074e383..dc52535e06328a6643567cfe0d45f64c28fdb511 100644 (file)
@@ -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);
                                                }