mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 13:12:03 +00:00
add support for running core-db over odbc
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15487 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -186,7 +186,7 @@ static switch_bool_t cidlookup_execute_sql_callback(char *sql, switch_core_db_ca
|
||||
|
||||
switch_mutex_lock(globals.db_mutex);
|
||||
if (globals.odbc_dsn) {
|
||||
if (switch_odbc_handle_callback_exec(globals.master_odbc, sql, callback, pdata)
|
||||
if (switch_odbc_handle_callback_exec(globals.master_odbc, sql, callback, pdata, NULL)
|
||||
== SWITCH_ODBC_FAIL) {
|
||||
retval = SWITCH_FALSE;
|
||||
} else {
|
||||
|
||||
@@ -2914,7 +2914,7 @@ SWITCH_STANDARD_API(show_function)
|
||||
{
|
||||
char sql[1024];
|
||||
char *errmsg;
|
||||
switch_core_db_t *db;
|
||||
switch_cache_db_handle_t *db;
|
||||
struct holder holder = { 0 };
|
||||
int help = 0;
|
||||
char *mydata = NULL, *argv[6] = { 0 };
|
||||
@@ -2923,7 +2923,7 @@ SWITCH_STANDARD_API(show_function)
|
||||
switch_core_flag_t cflags = switch_core_flags();
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
db = switch_core_db_handle();
|
||||
switch_core_db_handle(&db);
|
||||
|
||||
holder.justcount = 0;
|
||||
|
||||
@@ -3090,7 +3090,7 @@ SWITCH_STANDARD_API(show_function)
|
||||
holder.delim = ",";
|
||||
}
|
||||
}
|
||||
switch_core_db_exec(db, sql, show_callback, &holder, &errmsg);
|
||||
switch_cache_db_execute_sql_callback(db, sql, show_callback, &holder, &errmsg);
|
||||
if (holder.http) {
|
||||
holder.stream->write_function(holder.stream, "</table>");
|
||||
}
|
||||
@@ -3106,7 +3106,7 @@ SWITCH_STANDARD_API(show_function)
|
||||
stream->write_function(stream, "\n%u total.\n", holder.count);
|
||||
}
|
||||
} else if (!strcasecmp(as, "xml")) {
|
||||
switch_core_db_exec(db, sql, show_as_xml_callback, &holder, &errmsg);
|
||||
switch_cache_db_execute_sql_callback(db, sql, show_as_xml_callback, &holder, &errmsg);
|
||||
|
||||
if (errmsg) {
|
||||
stream->write_function(stream, "-ERR SQL Error [%s]\n", errmsg);
|
||||
@@ -3141,7 +3141,7 @@ SWITCH_STANDARD_API(show_function)
|
||||
switch_safe_free(mydata);
|
||||
|
||||
if (db) {
|
||||
switch_core_db_close(db);
|
||||
switch_cache_db_release_db_handle(&db);
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
@@ -336,7 +336,7 @@ SWITCH_STANDARD_APP(eavesdrop_function)
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
const char *require_group = switch_channel_get_variable(channel, "eavesdrop_require_group");
|
||||
if (!strcasecmp((char *) data, "all")) {
|
||||
switch_core_db_t *db = switch_core_db_handle();
|
||||
switch_cache_db_handle_t *db = NULL;
|
||||
char *errmsg = NULL;
|
||||
struct e_data e_data = { {0} };
|
||||
char *sql = switch_mprintf("select uuid from channels where uuid != '%q'", switch_core_session_get_uuid(session));
|
||||
@@ -347,12 +347,14 @@ SWITCH_STANDARD_APP(eavesdrop_function)
|
||||
char terminator;
|
||||
switch_status_t status;
|
||||
|
||||
switch_core_db_handle(&db);
|
||||
|
||||
while (switch_channel_ready(channel)) {
|
||||
for (x = 0; x < MAX_SPY; x++) {
|
||||
switch_safe_free(e_data.uuid_list[x]);
|
||||
}
|
||||
e_data.total = 0;
|
||||
switch_core_db_exec(db, sql, e_callback, &e_data, &errmsg);
|
||||
switch_cache_db_execute_sql_callback(db, sql, e_callback, &e_data, &errmsg);
|
||||
if (errmsg) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Error: %s\n", errmsg);
|
||||
switch_core_db_free(errmsg);
|
||||
@@ -393,7 +395,7 @@ SWITCH_STANDARD_APP(eavesdrop_function)
|
||||
}
|
||||
|
||||
free(sql);
|
||||
switch_core_db_close(db);
|
||||
switch_cache_db_release_db_handle(&db);
|
||||
|
||||
} else {
|
||||
switch_ivr_eavesdrop_session(session, data, require_group, ED_DTMF);
|
||||
|
||||
@@ -339,7 +339,7 @@ static switch_bool_t fifo_execute_sql_callback(switch_mutex_t *mutex, char *sql,
|
||||
}
|
||||
|
||||
if (switch_odbc_available() && globals.odbc_dsn) {
|
||||
switch_odbc_handle_callback_exec(globals.master_odbc, sql, callback, pdata);
|
||||
switch_odbc_handle_callback_exec(globals.master_odbc, sql, callback, pdata, NULL);
|
||||
} else {
|
||||
if (!(db = switch_core_db_open_file(globals.dbname))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", globals.dbname);
|
||||
|
||||
@@ -138,7 +138,7 @@ static switch_bool_t limit_execute_sql_callback(switch_mutex_t *mutex, char *sql
|
||||
}
|
||||
|
||||
if (switch_odbc_available() && globals.odbc_dsn) {
|
||||
switch_odbc_handle_callback_exec(globals.master_odbc, sql, callback, pdata);
|
||||
switch_odbc_handle_callback_exec(globals.master_odbc, sql, callback, pdata, NULL);
|
||||
} else {
|
||||
if (!(db = switch_core_db_open_file(globals.dbname))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", globals.dbname);
|
||||
|
||||
@@ -201,7 +201,7 @@ static switch_bool_t vm_execute_sql_callback(vm_profile_t *profile, switch_mutex
|
||||
}
|
||||
|
||||
if (switch_odbc_available() && profile->odbc_dsn) {
|
||||
switch_odbc_handle_callback_exec(profile->master_odbc, sql, callback, pdata);
|
||||
switch_odbc_handle_callback_exec(profile->master_odbc, sql, callback, pdata, NULL);
|
||||
} else {
|
||||
if (!(db = switch_core_db_open_file(profile->dbname))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
|
||||
|
||||
@@ -2876,7 +2876,8 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
switch_channel_t *nchannel;
|
||||
char *host = NULL, *dest_to = NULL;
|
||||
const char *hval = NULL;
|
||||
|
||||
char *not_const = NULL;
|
||||
|
||||
*new_session = NULL;
|
||||
|
||||
if (!outbound_profile || zstr(outbound_profile->destination_number)) {
|
||||
@@ -3115,10 +3116,12 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
|
||||
caller_profile = switch_caller_profile_clone(nsession, outbound_profile);
|
||||
|
||||
|
||||
|
||||
caller_profile->destination_number = switch_sanitize_number(caller_profile->destination_number);
|
||||
caller_profile->caller_id_name = switch_sanitize_number((char *)caller_profile->caller_id_name);
|
||||
caller_profile->caller_id_number = switch_sanitize_number((char *)caller_profile->caller_id_number);
|
||||
not_const = (char *)caller_profile->caller_id_name;
|
||||
caller_profile->caller_id_name = switch_sanitize_number(not_const);
|
||||
not_const = (char *)caller_profile->caller_id_number;
|
||||
caller_profile->caller_id_number = switch_sanitize_number(not_const);
|
||||
|
||||
//caller_profile->destination_number = switch_core_strdup(caller_profile->pool, dest_num);
|
||||
switch_channel_set_caller_profile(nchannel, caller_profile);
|
||||
|
||||
@@ -4008,12 +4008,14 @@ void sofia_glue_sql_close(sofia_profile_t *profile, time_t prune)
|
||||
if ((dbh = (sofia_cache_db_handle_t *) val)) {
|
||||
time_t diff = 0;
|
||||
|
||||
if (prune > 0 && prune > dbh->last_used) {
|
||||
diff = (time_t) prune - dbh->last_used;
|
||||
}
|
||||
if (prune > 0) {
|
||||
if (prune > dbh->last_used) {
|
||||
diff = (time_t) prune - dbh->last_used;
|
||||
}
|
||||
|
||||
if (diff < SQL_CACHE_TIMEOUT) {
|
||||
continue;
|
||||
if (diff < SQL_CACHE_TIMEOUT) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (switch_mutex_trylock(dbh->mutex) == SWITCH_STATUS_SUCCESS) {
|
||||
@@ -4121,7 +4123,7 @@ sofia_cache_db_handle_t *sofia_glue_get_db_handle(sofia_profile_t *profile)
|
||||
|
||||
|
||||
if (db) dbh->db = db; else dbh->odbc_dbh = odbc_dbh;
|
||||
switch_mutex_init(&dbh->mutex, SWITCH_MUTEX_NESTED, dbh->pool);
|
||||
switch_mutex_init(&dbh->mutex, 0, dbh->pool);
|
||||
switch_mutex_lock(dbh->mutex);
|
||||
|
||||
switch_core_hash_insert(profile->db_hash, thread_str, dbh);
|
||||
@@ -4202,7 +4204,7 @@ switch_bool_t sofia_glue_execute_sql_callback(sofia_profile_t *profile,
|
||||
}
|
||||
|
||||
if (switch_odbc_available() && dbh->odbc_dbh) {
|
||||
switch_odbc_handle_callback_exec(dbh->odbc_dbh, sql, callback, pdata);
|
||||
switch_odbc_handle_callback_exec(dbh->odbc_dbh, sql, callback, pdata, NULL);
|
||||
} else if (profile->odbc_dsn) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
|
||||
} else {
|
||||
|
||||
@@ -1678,7 +1678,9 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile,
|
||||
if ((regtype == REG_REGISTER) && sofia_test_pflag(profile, PFLAG_CHECKUSER)) {
|
||||
if (zstr(username) || zstr(to_user) || strcasecmp(to_user, username)) {
|
||||
/* Names don't match, so fail */
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SIP username %s does not match auth username\n", switch_str_nil(to_user));
|
||||
if (profile->debug) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SIP username %s does not match auth username\n", switch_str_nil(to_user));
|
||||
}
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user