add <param name="core-odbc-required" value="true"/> to require connection to core db over odbc for startup

This commit is contained in:
Anthony Minessale 2011-10-17 09:34:50 -05:00
parent 4bd305e57d
commit ead7a68276
3 changed files with 22 additions and 8 deletions

View File

@ -309,7 +309,8 @@ typedef enum {
SCF_USE_NAT_MAPPING = (1 << 15),
SCF_CLEAR_SQL = (1 << 16),
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;
typedef uint32_t switch_core_flag_t;

View File

@ -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);
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();
@ -1783,6 +1784,8 @@ static void switch_load_core_config(const char *file)
} else {
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)) {
if (!strcasecmp(val, "MSSQL")) {
runtime.odbc_dbtype = DBTYPE_MSSQL;

View File

@ -188,19 +188,24 @@ SWITCH_DECLARE(switch_status_t) _switch_core_db_handle(switch_cache_db_handle_t
return SWITCH_STATUS_FALSE;
}
if (!zstr(runtime.odbc_dsn)) {
options.odbc_options.dsn = runtime.odbc_dsn;
options.odbc_options.user = runtime.odbc_user;
options.odbc_options.pass = runtime.odbc_pass;
if (zstr(runtime.odbc_dsn)) {
if (switch_test_flag((&runtime), SCF_CORE_ODBC_REQ)) {
return SWITCH_STATUS_FALSE;
}
r = _switch_cache_db_get_db_handle(dbh, SCDB_TYPE_ODBC, &options, file, func, line);
} else {
if (runtime.dbname) {
options.core_db_options.db_path = runtime.dbname;
} else {
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);
} 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
@ -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) {
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) {
runtime.odbc_dsn = NULL;
runtime.odbc_user = NULL;