mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-14 21:38:34 +00:00
refactor db stuff to use single string dsn to avoid code duplication and introduce switch_sql_queue_manager api to create transactional sql queues to aggregate a bunch of sql stmts into transactions
This commit is contained in:
1 parent
fc764b27bf
commit
e1fe289672
20 files changed
+766
-553
No files matched your search
@@ -44,8 +44,6 @@ static struct {
|
||||
char hostname[256];
|
||||
char *dbname;
|
||||
char *odbc_dsn;
|
||||
char *odbc_user;
|
||||
char *odbc_pass;
|
||||
switch_mutex_t *mutex;
|
||||
switch_mutex_t *db_hash_mutex;
|
||||
switch_hash_t *db_hash;
|
||||
@@ -88,31 +86,21 @@ static char group_sql[] =
|
||||
|
||||
switch_cache_db_handle_t *limit_get_db_handle(void)
|
||||
{
|
||||
switch_cache_db_connection_options_t options = { {0} };
|
||||
switch_cache_db_handle_t *dbh = NULL;
|
||||
|
||||
char *dsn;
|
||||
|
||||
if (!zstr(globals.odbc_dsn)) {
|
||||
char *dsn;
|
||||
if ((dsn = strstr(globals.odbc_dsn, "pgsql;")) != NULL) {
|
||||
options.pgsql_options.dsn = (char*)(dsn + 6);
|
||||
|
||||
if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_PGSQL, &options) != SWITCH_STATUS_SUCCESS)
|
||||
dbh = NULL;
|
||||
} else {
|
||||
options.odbc_options.dsn = globals.odbc_dsn;
|
||||
options.odbc_options.user = globals.odbc_user;
|
||||
options.odbc_options.pass = globals.odbc_pass;
|
||||
|
||||
if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_ODBC, &options) != SWITCH_STATUS_SUCCESS)
|
||||
dbh = NULL;
|
||||
}
|
||||
return dbh;
|
||||
dsn = globals.odbc_dsn;
|
||||
} else {
|
||||
options.core_db_options.db_path = globals.dbname;
|
||||
if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_CORE_DB, &options) != SWITCH_STATUS_SUCCESS)
|
||||
dbh = NULL;
|
||||
return dbh;
|
||||
dsn = globals.dbname;
|
||||
}
|
||||
|
||||
if (switch_cache_db_get_db_handle_dsn(&dbh, dsn) != SWITCH_STATUS_SUCCESS) {
|
||||
dbh = NULL;
|
||||
}
|
||||
|
||||
return dbh;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -304,15 +292,8 @@ static switch_status_t do_config()
|
||||
}
|
||||
|
||||
if (globals.odbc_dsn) {
|
||||
if ((globals.odbc_user = strchr(globals.odbc_dsn, ':'))) {
|
||||
*globals.odbc_user++ = '\0';
|
||||
if ((globals.odbc_pass = strchr(globals.odbc_user, ':'))) {
|
||||
*globals.odbc_pass++ = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (!(dbh = limit_get_db_handle())) {
|
||||
globals.odbc_dsn = globals.odbc_user = globals.odbc_pass;
|
||||
globals.odbc_dsn = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user