mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-19 09:47:23 +00:00
add <param name="core-odbc-required" value="true"/> to require connection to core db over odbc for startup
This commit is contained in:
parent
4bd305e57d
commit
ead7a68276
@ -309,7 +309,8 @@ typedef enum {
|
|||||||
SCF_USE_NAT_MAPPING = (1 << 15),
|
SCF_USE_NAT_MAPPING = (1 << 15),
|
||||||
SCF_CLEAR_SQL = (1 << 16),
|
SCF_CLEAR_SQL = (1 << 16),
|
||||||
SCF_THREADED_SYSTEM_EXEC = (1 << 17),
|
SCF_THREADED_SYSTEM_EXEC = (1 << 17),
|
||||||
SCF_SYNC_CLOCK_REQUESTED = (1 << 18)
|
SCF_SYNC_CLOCK_REQUESTED = (1 << 18),
|
||||||
|
SCF_CORE_ODBC_REQ = (1 << 19)
|
||||||
} switch_core_flag_enum_t;
|
} switch_core_flag_enum_t;
|
||||||
typedef uint32_t switch_core_flag_t;
|
typedef uint32_t switch_core_flag_t;
|
||||||
|
|
||||||
|
@ -1493,7 +1493,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
|
|||||||
switch_core_state_machine_init(runtime.memory_pool);
|
switch_core_state_machine_init(runtime.memory_pool);
|
||||||
|
|
||||||
if (switch_core_sqldb_start(runtime.memory_pool, switch_test_flag((&runtime), SCF_USE_SQL) ? SWITCH_TRUE : SWITCH_FALSE) != SWITCH_STATUS_SUCCESS) {
|
if (switch_core_sqldb_start(runtime.memory_pool, switch_test_flag((&runtime), SCF_USE_SQL) ? SWITCH_TRUE : SWITCH_FALSE) != SWITCH_STATUS_SUCCESS) {
|
||||||
abort();
|
*err = "Error activating database";
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_scheduler_task_thread_start();
|
switch_scheduler_task_thread_start();
|
||||||
@ -1783,6 +1784,8 @@ static void switch_load_core_config(const char *file)
|
|||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
|
||||||
}
|
}
|
||||||
|
} else if (!strcasecmp(var, "core-odbc-required") && !zstr(val)) {
|
||||||
|
switch_set_flag((&runtime), SCF_CORE_ODBC_REQ);
|
||||||
} else if (!strcasecmp(var, "core-dbtype") && !zstr(val)) {
|
} else if (!strcasecmp(var, "core-dbtype") && !zstr(val)) {
|
||||||
if (!strcasecmp(val, "MSSQL")) {
|
if (!strcasecmp(val, "MSSQL")) {
|
||||||
runtime.odbc_dbtype = DBTYPE_MSSQL;
|
runtime.odbc_dbtype = DBTYPE_MSSQL;
|
||||||
|
@ -188,19 +188,24 @@ SWITCH_DECLARE(switch_status_t) _switch_core_db_handle(switch_cache_db_handle_t
|
|||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!zstr(runtime.odbc_dsn)) {
|
if (zstr(runtime.odbc_dsn)) {
|
||||||
options.odbc_options.dsn = runtime.odbc_dsn;
|
if (switch_test_flag((&runtime), SCF_CORE_ODBC_REQ)) {
|
||||||
options.odbc_options.user = runtime.odbc_user;
|
return SWITCH_STATUS_FALSE;
|
||||||
options.odbc_options.pass = runtime.odbc_pass;
|
}
|
||||||
|
|
||||||
r = _switch_cache_db_get_db_handle(dbh, SCDB_TYPE_ODBC, &options, file, func, line);
|
|
||||||
} else {
|
|
||||||
if (runtime.dbname) {
|
if (runtime.dbname) {
|
||||||
options.core_db_options.db_path = runtime.dbname;
|
options.core_db_options.db_path = runtime.dbname;
|
||||||
} else {
|
} else {
|
||||||
options.core_db_options.db_path = SWITCH_CORE_DB;
|
options.core_db_options.db_path = SWITCH_CORE_DB;
|
||||||
}
|
}
|
||||||
r = _switch_cache_db_get_db_handle(dbh, SCDB_TYPE_CORE_DB, &options, file, func, line);
|
r = _switch_cache_db_get_db_handle(dbh, SCDB_TYPE_CORE_DB, &options, file, func, line);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
options.odbc_options.dsn = runtime.odbc_dsn;
|
||||||
|
options.odbc_options.user = runtime.odbc_user;
|
||||||
|
options.odbc_options.pass = runtime.odbc_pass;
|
||||||
|
|
||||||
|
r = _switch_cache_db_get_db_handle(dbh, SCDB_TYPE_ODBC, &options, file, func, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* I *think* we can do without this now, if not let me know
|
/* I *think* we can do without this now, if not let me know
|
||||||
@ -1880,6 +1885,11 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
|
|||||||
if (switch_core_db_handle(&dbh) != SWITCH_STATUS_SUCCESS) {
|
if (switch_core_db_handle(&dbh) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB!\n");
|
||||||
|
|
||||||
|
if (switch_test_flag((&runtime), SCF_CORE_ODBC_REQ)) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure! ODBC IS REQUIRED!\n");
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (runtime.odbc_dsn) {
|
if (runtime.odbc_dsn) {
|
||||||
runtime.odbc_dsn = NULL;
|
runtime.odbc_dsn = NULL;
|
||||||
runtime.odbc_user = NULL;
|
runtime.odbc_user = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user