FreeSWITCH API Documentation
1.7.0
|
Go to the source code of this file.
Data Structures | |
struct | switch_cache_db_handle |
struct | helper |
struct | switch_sql_queue_manager |
struct | db_job |
Macros | |
#define | SWITCH_SQL_QUEUE_LEN 100000 |
#define | SWITCH_SQL_QUEUE_PAUSE_LEN 90000 |
#define | SQL_CACHE_TIMEOUT 30 |
#define | SQL_REG_TIMEOUT 15 |
#define | EXEC_NOW |
#define | MAX_SQL 5 |
#define | new_sql() switch_assert(sql_idx+1 < MAX_SQL); if (exists) sql[sql_idx++] |
#define | new_sql_a() switch_assert(sql_idx+1 < MAX_SQL); sql[sql_idx++] |
Variables | |
struct { | |
switch_memory_pool_t * memory_pool | |
switch_thread_t * db_thread | |
int db_thread_running | |
switch_bool_t manage | |
switch_mutex_t * io_mutex | |
switch_mutex_t * dbh_mutex | |
switch_mutex_t * ctl_mutex | |
switch_cache_db_handle_t * handle_pool | |
uint32_t total_handles | |
uint32_t total_used_handles | |
switch_cache_db_handle_t * dbh | |
switch_sql_queue_manager_t * qm | |
int paused | |
} | sql_manager |
static char | create_complete_sql [] |
static char | create_alias_sql [] |
static char | create_channels_sql [] |
static char | create_calls_sql [] |
static char | create_interfaces_sql [] |
static char | create_tasks_sql [] |
static char | create_nat_sql [] |
static char | create_registrations_sql [] |
static char | detailed_calls_sql [] |
static char | recovery_sql [] |
static char | basic_calls_sql [] |
#define EXEC_NOW |
#define MAX_SQL 5 |
Definition at line 2203 of file switch_core_sqldb.c.
Referenced by core_event_handler().
#define new_sql | ( | ) | switch_assert(sql_idx+1 < MAX_SQL); if (exists) sql[sql_idx++] |
Definition at line 2204 of file switch_core_sqldb.c.
Referenced by core_event_handler().
#define new_sql_a | ( | ) | switch_assert(sql_idx+1 < MAX_SQL); sql[sql_idx++] |
Definition at line 2205 of file switch_core_sqldb.c.
Referenced by core_event_handler().
#define SQL_CACHE_TIMEOUT 30 |
Definition at line 208 of file switch_core_sqldb.c.
Referenced by sql_close(), switch_cache_db_execute_sql_callback(), switch_cache_db_execute_sql_callback_err(), switch_cache_db_execute_sql_event_callback(), switch_cache_db_execute_sql_event_callback_err(), switch_cache_db_flush_handles(), and switch_core_sql_db_thread().
#define SQL_REG_TIMEOUT 15 |
Definition at line 209 of file switch_core_sqldb.c.
Referenced by switch_core_sql_db_thread().
#define SWITCH_SQL_QUEUE_LEN 100000 |
Definition at line 39 of file switch_core_sqldb.c.
Referenced by switch_sql_queue_manager_init_name().
#define SWITCH_SQL_QUEUE_PAUSE_LEN 90000 |
Definition at line 40 of file switch_core_sqldb.c.
switch_status_t _switch_cache_db_get_db_handle | ( | switch_cache_db_handle_t ** | dbh, |
switch_cache_db_handle_type_t | type, | ||
switch_cache_db_connection_options_t * | connection_options, | ||
const char * | file, | ||
const char * | func, | ||
int | line | ||
) |
Gets a new cached handle from the pool, potentially creating a new connection. The connection is bound to the thread until it (the thread) terminates unless you dismiss rather than release.
[out] | dbh | The handle |
[in] | type | - ODBC or SQLLITE |
[in] | connection_options | (userid, password, etc) |
Definition at line 384 of file switch_core_sqldb.c.
References add_handle(), CACHE_DB_LEN, switch_cache_db_native_handle_t::core_db_dbh, create_handle(), switch_runtime::db_handle_timeout, get_handle(), switch_cache_db_handle::last_used, switch_runtime::max_db_handles, switch_cache_db_handle::name, switch_cache_db_handle::native_handle, switch_cache_db_native_handle_t::odbc_dbh, switch_cache_db_native_handle_t::pgsql_dbh, runtime, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, sql_manager, switch_cache_db_type_name(), SWITCH_CHANNEL_ID_LOG, SWITCH_CHANNEL_LOG, switch_core_db_open_file(), switch_epoch_time_now(), SWITCH_LOG_CRIT, SWITCH_LOG_DEBUG10, SWITCH_LOG_ERROR, switch_log_printf(), SWITCH_LOG_WARNING, switch_odbc_available(), switch_odbc_handle_connect(), switch_odbc_handle_destroy(), switch_odbc_handle_new(), SWITCH_ODBC_SUCCESS, switch_pgsql_available(), switch_pgsql_handle_connect(), switch_pgsql_handle_destroy(), switch_pgsql_handle_new(), SWITCH_PGSQL_SUCCESS, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_thread_self(), switch_yield, and switch_cache_db_handle::type.
Referenced by _switch_cache_db_get_db_handle_dsn().
switch_status_t _switch_cache_db_get_db_handle_dsn | ( | switch_cache_db_handle_t ** | dbh, |
const char * | dsn, | ||
const char * | file, | ||
const char * | func, | ||
int | line | ||
) |
Definition at line 335 of file switch_core_sqldb.c.
References _switch_cache_db_get_db_handle(), switch_cache_db_connection_options_t::core_db_options, switch_cache_db_core_db_options_t::db_path, switch_cache_db_odbc_options_t::dsn, switch_cache_db_pgsql_options_t::dsn, switch_cache_db_connection_options_t::odbc_options, switch_cache_db_odbc_options_t::pass, switch_cache_db_connection_options_t::pgsql_options, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, switch_set_string, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_cache_db_odbc_options_t::user.
Referenced by _switch_core_db_handle().
switch_status_t _switch_core_db_handle | ( | switch_cache_db_handle_t ** | dbh, |
const char * | file, | ||
const char * | func, | ||
int | line | ||
) |
Open the default system database.
Definition at line 184 of file switch_core_sqldb.c.
References _switch_cache_db_get_db_handle_dsn(), switch_runtime::dbname, switch_runtime::odbc_dsn, runtime, sql_manager, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and zstr.
|
static |
Definition at line 94 of file switch_core_sqldb.c.
References switch_cache_db_handle::creator, dbh, switch_cache_db_handle::hash, switch_cache_db_handle::mutex, switch_cache_db_handle::name, switch_cache_db_handle::next, sql_manager, switch_ci_hashfunc_default(), switch_mutex_lock(), switch_mutex_unlock(), switch_set_string, switch_cache_db_handle::thread_hash, switch_cache_db_handle::total_used_count, and switch_cache_db_handle::use_count.
Referenced by _switch_cache_db_get_db_handle().
|
static |
Definition at line 2207 of file switch_core_sqldb.c.
References CCS_DOWN, CCS_HANGUP, CS_DESTROY, CS_EXECUTE, CS_HANGUP, CS_INIT, CS_NEW, CS_REPORTING, CS_ROUTING, switch_event::event_id, filename, MAX_SQL, new_sql, new_sql_a, parse_presence_data_cols(), db_job::sql, sql_manager, switch_assert, SWITCH_CHANNEL_LOG, switch_core_get_hostname(), switch_core_get_switchname(), switch_epoch_time_now(), SWITCH_EVENT_ADD_SCHEDULE, SWITCH_EVENT_CALL_SECURE, SWITCH_EVENT_CALL_UPDATE, SWITCH_EVENT_CHANNEL_ANSWER, SWITCH_EVENT_CHANNEL_BRIDGE, SWITCH_EVENT_CHANNEL_CALLSTATE, SWITCH_EVENT_CHANNEL_CREATE, SWITCH_EVENT_CHANNEL_DESTROY, SWITCH_EVENT_CHANNEL_EXECUTE, SWITCH_EVENT_CHANNEL_HOLD, SWITCH_EVENT_CHANNEL_ORIGINATE, SWITCH_EVENT_CHANNEL_PROGRESS_MEDIA, SWITCH_EVENT_CHANNEL_STATE, SWITCH_EVENT_CHANNEL_UNBRIDGE, SWITCH_EVENT_CHANNEL_UNHOLD, SWITCH_EVENT_CHANNEL_UUID, SWITCH_EVENT_CODEC, SWITCH_EVENT_DEL_SCHEDULE, SWITCH_EVENT_EXE_SCHEDULE, switch_event_get_header, switch_event_get_header_nil, SWITCH_EVENT_LOG, SWITCH_EVENT_MODULE_LOAD, SWITCH_EVENT_MODULE_UNLOAD, SWITCH_EVENT_NAT, SWITCH_EVENT_RE_SCHEDULE, SWITCH_EVENT_SHUTDOWN, SWITCH_FALSE, switch_ivr_uuid_exists(), SWITCH_LOG_DEBUG, SWITCH_LOG_ERROR, switch_log_printf(), switch_mprintf(), switch_safe_free, switch_sql_queue_manager_push(), switch_str_nil, switch_stristr(), switch_true(), and zstr.
Referenced by switch_core_sqldb_start(), and switch_core_sqldb_stop().
|
static |
Definition at line 80 of file switch_core_sqldb.c.
References switch_cache_db_handle::mutex, switch_cache_db_handle::pool, pool, switch_core_alloc, switch_core_new_memory_pool, switch_mutex_init(), SWITCH_MUTEX_NESTED, and switch_cache_db_handle::type.
Referenced by _switch_cache_db_get_db_handle().
|
static |
Definition at line 117 of file switch_core_sqldb.c.
References switch_cache_db_handle::next, sql_manager, switch_mutex_lock(), and switch_mutex_unlock().
Referenced by sql_close().
|
static |
Definition at line 1597 of file switch_core_sqldb.c.
References switch_sql_queue_manager::mutex, switch_sql_queue_manager::sql_queue, switch_cache_db_execute_sql(), switch_mutex_lock(), switch_mutex_unlock(), switch_queue_trypop(), switch_safe_free, and SWITCH_STATUS_SUCCESS.
Referenced by switch_sql_queue_manager_destroy(), switch_sql_queue_manager_pause(), and switch_user_sql_thread().
|
static |
Definition at line 1902 of file switch_core_sqldb.c.
References switch_sql_queue_manager::event_db, switch_sql_queue_manager::inner_post_trans_execute, switch_sql_queue_manager::inner_pre_trans_execute, switch_cache_db_handle::io_mutex, io_mutex, switch_sql_queue_manager::max_trans, switch_sql_queue_manager::mutex, switch_cache_db_handle::native_handle, switch_sql_queue_manager::numq, switch_cache_db_native_handle_t::odbc_dbh, switch_cache_db_native_handle_t::pgsql_dbh, switch_sql_queue_manager::post_trans_execute, switch_sql_queue_manager::pre_trans_execute, switch_sql_queue_manager::pre_written, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, switch_sql_queue_manager::sql_queue, switch_cache_db_execute_sql(), switch_cache_db_execute_sql_real(), SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_SQLEndTran(), switch_odbc_SQLSetAutoCommitAttr(), SWITCH_ODBC_SUCCESS, switch_pgsql_finish_results, switch_pgsql_SQLEndTran(), switch_pgsql_SQLSetAutoCommitAttr(), SWITCH_PGSQL_SUCCESS, switch_queue_trypop(), switch_safe_free, switch_snprintfv(), SWITCH_STATUS_SUCCESS, switch_cache_db_handle::type, switch_sql_queue_manager::written, and zstr.
Referenced by switch_user_sql_thread().
|
static |
Definition at line 138 of file switch_core_sqldb.c.
References CDF_PRUNE, switch_cache_db_handle::hash, hash, switch_cache_db_handle::last_user, switch_cache_db_handle::mutex, switch_cache_db_handle::next, SCDB_TYPE_PGSQL, sql_manager, switch_ci_hashfunc_default(), switch_mutex_lock(), switch_mutex_trylock(), switch_mutex_unlock(), switch_set_string, SWITCH_STATUS_SUCCESS, switch_test_flag, switch_cache_db_handle::thread_hash, switch_cache_db_handle::total_used_count, switch_cache_db_handle::type, and switch_cache_db_handle::use_count.
Referenced by _switch_cache_db_get_db_handle().
|
static |
Definition at line 1027 of file switch_core_sqldb.c.
References helper::callback, helper::pdata, switch_event_create_array_pair(), and switch_event_destroy().
Referenced by switch_cache_db_execute_sql_event_callback(), and switch_cache_db_execute_sql_event_callback_err().
|
static |
Definition at line 1517 of file switch_core_sqldb.c.
References db_job::callback, db_job::err_callback, db_job::event_callback, db_job::event_err_callback, switch_thread_data_s::func, switch_thread_data_s::obj, db_job::pdata, pool, db_job::pool, qm, db_job::qm, db_job::sql, sql_in_thread(), switch_core_alloc, switch_core_new_memory_pool, and switch_core_strdup.
Referenced by switch_sql_queue_manager_execute_sql_callback(), switch_sql_queue_manager_execute_sql_callback_err(), switch_sql_queue_manager_execute_sql_event_callback(), and switch_sql_queue_manager_execute_sql_event_callback_err().
|
static |
Definition at line 2157 of file switch_core_sqldb.c.
References switch_stream_handle::data, end_of, if(), switch_event_get_header, switch_event_get_header_nil, switch_safe_free, switch_snprintfv(), switch_split, SWITCH_STANDARD_STREAM, switch_stream_handle::write_function, and zstr.
Referenced by core_event_handler().
|
static |
Definition at line 1456 of file switch_core_sqldb.c.
References switch_sql_queue_manager::numq, switch_sql_queue_manager::sql_queue, and switch_queue_size().
Referenced by switch_user_sql_thread().
|
static |
Definition at line 1429 of file switch_core_sqldb.c.
References switch_sql_queue_manager::cond, switch_sql_queue_manager::cond2_mutex, switch_sql_queue_manager::cond_mutex, switch_cond_next(), switch_mutex_trylock(), switch_mutex_unlock(), SWITCH_STATUS_SUCCESS, and switch_thread_cond_signal().
Referenced by switch_sql_queue_manager_push(), switch_sql_queue_manager_push_confirm(), switch_sql_queue_manager_resume(), and switch_sql_queue_manager_stop().
|
static |
Definition at line 2950 of file switch_core_sqldb.c.
References CF_RECOVERING, CF_RECOVERING_BRIDGE, switch_core_session::channel, CS_INIT, ep, switch_xml::next, switch_endpoint_interface::recover_callback, switch_caller_extension_add_application(), switch_caller_extension_new(), switch_channel_get_name(), switch_channel_get_partner_uuid(), switch_channel_get_variable, SWITCH_CHANNEL_LOG, SWITCH_CHANNEL_SESSION_LOG, switch_channel_set_caller_extension(), switch_channel_set_flag, switch_channel_set_state, switch_channel_test_flag(), switch_core_get_secondary_recover_callback(), switch_core_media_recover_session(), switch_core_session_get_channel(), switch_core_session_request_xml(), switch_core_session_thread_launch(), switch_loadable_module_get_endpoint_interface(), SWITCH_LOG_NOTICE, switch_log_printf(), SWITCH_LOG_WARNING, SWITCH_TRUE, switch_xml_attr_soft(), switch_xml_child(), switch_xml_free(), switch_xml_parse_str_dynamic(), and UNPROTECT_INTERFACE.
Referenced by switch_core_recovery_recover().
|
static |
Definition at line 212 of file switch_core_sqldb.c.
References CDF_PRUNE, switch_cache_db_native_handle_t::core_db_dbh, switch_cache_db_handle::creator, dbh, del_handle(), switch_cache_db_handle::last_used, switch_cache_db_handle::last_user, switch_cache_db_handle::mutex, switch_cache_db_handle::name, switch_cache_db_handle::native_handle, switch_cache_db_handle::next, switch_cache_db_native_handle_t::odbc_dbh, switch_cache_db_native_handle_t::pgsql_dbh, switch_cache_db_handle::pool, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, SQL_CACHE_TIMEOUT, sql_manager, SWITCH_CHANNEL_LOG, switch_cond_next(), switch_core_db_close(), switch_core_destroy_memory_pool, SWITCH_LOG_CRIT, SWITCH_LOG_DEBUG10, switch_log_printf(), switch_mutex_lock(), switch_mutex_trylock(), switch_mutex_unlock(), switch_odbc_handle_destroy(), switch_pgsql_handle_destroy(), SWITCH_STATUS_SUCCESS, switch_test_flag, switch_cache_db_handle::type, and switch_cache_db_handle::use_count.
Referenced by switch_cache_db_flush_handles(), switch_core_sql_db_thread(), and switch_core_sqldb_stop().
|
static |
Definition at line 1480 of file switch_core_sqldb.c.
References db_job::callback, dbh, switch_sql_queue_manager::dsn, db_job::err_callback, db_job::event_callback, db_job::event_err_callback, db_job::pdata, pool, db_job::pool, db_job::qm, db_job::sql, switch_cache_db_execute_sql_callback(), switch_cache_db_execute_sql_callback_err(), switch_cache_db_execute_sql_event_callback(), switch_cache_db_execute_sql_event_callback_err(), switch_cache_db_get_db_handle_dsn, switch_cache_db_release_db_handle(), SWITCH_CHANNEL_LOG, switch_core_destroy_memory_pool, SWITCH_LOG_ERROR, switch_log_printf(), switch_safe_free, and SWITCH_STATUS_SUCCESS.
Referenced by new_job().
int switch_cache_db_affected_rows | ( | switch_cache_db_handle_t * | dbh | ) |
Get the affected rows of the last performed query.
[in] | dbh | The handle |
[out] | the | number of affected rows |
Definition at line 688 of file switch_core_sqldb.c.
References SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, switch_core_db_changes(), switch_odbc_handle_affected_rows(), and switch_pgsql_handle_affected_rows().
switch_status_t switch_cache_db_create_schema | ( | switch_cache_db_handle_t * | dbh, |
char * | sql, | ||
char ** | err | ||
) |
Executes the create schema sql.
[in] | dbh | The handle |
[in] | sql | - sql to run |
[out] | err | - Error if it exists |
Definition at line 1271 of file switch_core_sqldb.c.
References runtime, SCF_AUTO_SCHEMAS, switch_assert, switch_cache_db_execute_sql(), SWITCH_STATUS_SUCCESS, and switch_test_flag.
Referenced by switch_core_sqldb_start().
void switch_cache_db_dismiss_db_handle | ( | switch_cache_db_handle_t ** | dbh | ) |
Returns the handle to the pool, immediately available for other threads to use.
[in] | The | handle |
Definition at line 329 of file switch_core_sqldb.c.
References switch_cache_db_release_db_handle().
switch_status_t switch_cache_db_execute_sql | ( | switch_cache_db_handle_t * | dbh, |
char * | sql, | ||
char ** | err | ||
) |
Executes the sql.
[in] | dbh | The handle |
[in] | sql | - sql to run |
[out] | err | - Error if it exists |
Definition at line 666 of file switch_core_sqldb.c.
References io_mutex, switch_cache_db_execute_sql_chunked(), switch_mutex_lock(), switch_mutex_unlock(), and SWITCH_STATUS_FALSE.
Referenced by do_flush(), do_trans(), switch_cache_db_create_schema(), switch_cache_db_persistant_execute_trans_full(), switch_cache_db_test_reactive(), switch_core_recovery_flush(), switch_core_recovery_recover(), switch_core_sqldb_start(), switch_sql_queue_manager_push_confirm(), and switch_user_sql_thread().
char* switch_cache_db_execute_sql2str | ( | switch_cache_db_handle_t * | dbh, |
char * | sql, | ||
char * | str, | ||
size_t | len, | ||
char ** | err | ||
) |
Executes the sql and returns the result as a string.
[in] | dbh | The handle |
[in] | sql | - sql to run |
[out] | str | - buffer for result |
[in] | len | - length of str buffer |
[out] | err | - Error if it exists |
Definition at line 734 of file switch_core_sqldb.c.
References io_mutex, memset(), running, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, SWITCH_CHANNEL_LOG, switch_cond_next(), switch_copy_string(), SWITCH_CORE_DB_BUSY, switch_core_db_column_count(), switch_core_db_column_text(), switch_core_db_finalize(), switch_core_db_prepare(), SWITCH_CORE_DB_ROW, switch_core_db_step(), SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_handle_exec_string(), switch_pgsql_handle_exec_string, SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.
switch_status_t switch_cache_db_execute_sql_callback | ( | switch_cache_db_handle_t * | dbh, |
const char * | sql, | ||
switch_core_db_callback_func_t | callback, | ||
void * | pdata, | ||
char ** | err | ||
) |
Executes the sql and uses callback for row-by-row processing.
[in] | dbh | The handle |
[in] | sql | - sql to run |
[in] | callback | - function pointer to callback |
[in] | pdata | - data to pass to callback |
[out] | err | - Error if it exists |
Definition at line 1161 of file switch_core_sqldb.c.
References io_mutex, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, SQL_CACHE_TIMEOUT, SWITCH_CHANNEL_LOG, SWITCH_CORE_DB_ABORT, switch_core_db_exec(), switch_core_db_free(), SWITCH_CORE_DB_OK, switch_epoch_time_now(), SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_handle_callback_exec, switch_pgsql_handle_callback_exec, SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.
Referenced by sql_in_thread(), switch_console_complete(), switch_console_expand_alias(), switch_console_list_uuid(), and switch_core_recovery_recover().
switch_status_t switch_cache_db_execute_sql_callback_err | ( | switch_cache_db_handle_t * | dbh, |
const char * | sql, | ||
switch_core_db_callback_func_t | callback, | ||
switch_core_db_err_callback_func_t | err_callback, | ||
void * | pdata, | ||
char ** | err | ||
) |
Executes the sql and uses callback for row-by-row processing.
[in] | dbh | The handle |
[in] | sql | - sql to run |
[in] | callback | - function pointer to callback |
[in] | err_callback | - function pointer to callback when error occurs |
[in] | pdata | - data to pass to callback |
[out] | err | - Error if it exists |
Definition at line 1210 of file switch_core_sqldb.c.
References io_mutex, helper::pdata, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, SQL_CACHE_TIMEOUT, SWITCH_CHANNEL_LOG, SWITCH_CORE_DB_ABORT, switch_core_db_exec(), switch_core_db_free(), SWITCH_CORE_DB_OK, switch_epoch_time_now(), SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_handle_callback_exec, switch_pgsql_handle_callback_exec, SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.
Referenced by sql_in_thread().
|
static |
OMFG you cruel bastards. Who chooses 64k as a max buffer len for a sql statement, have you ever heard of transactions?
Definition at line 605 of file switch_core_sqldb.c.
References end_of_p, switch_assert, switch_cache_db_execute_sql_real(), SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.
Referenced by switch_cache_db_execute_sql().
switch_status_t switch_cache_db_execute_sql_event_callback | ( | switch_cache_db_handle_t * | dbh, |
const char * | sql, | ||
switch_core_db_event_callback_func_t | callback, | ||
void * | pdata, | ||
char ** | err | ||
) |
Definition at line 1042 of file switch_core_sqldb.c.
References helper::callback, helper_callback(), io_mutex, helper::pdata, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, SQL_CACHE_TIMEOUT, SWITCH_CHANNEL_LOG, SWITCH_CORE_DB_ABORT, switch_core_db_exec(), switch_core_db_free(), SWITCH_CORE_DB_OK, switch_epoch_time_now(), SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_handle_callback_exec, switch_pgsql_handle_callback_exec, SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.
Referenced by sql_in_thread().
switch_status_t switch_cache_db_execute_sql_event_callback_err | ( | switch_cache_db_handle_t * | dbh, |
const char * | sql, | ||
switch_core_db_event_callback_func_t | callback, | ||
switch_core_db_err_callback_func_t | err_callback, | ||
void * | pdata, | ||
char ** | err | ||
) |
Definition at line 1095 of file switch_core_sqldb.c.
References helper::callback, helper_callback(), io_mutex, helper::pdata, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, SQL_CACHE_TIMEOUT, SWITCH_CHANNEL_LOG, SWITCH_CORE_DB_ABORT, switch_core_db_exec(), switch_core_db_free(), SWITCH_CORE_DB_OK, switch_epoch_time_now(), SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_handle_callback_exec, switch_pgsql_handle_callback_exec, SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.
Referenced by sql_in_thread().
|
static |
Definition at line 540 of file switch_core_sqldb.c.
References switch_cache_db_native_handle_t::core_db_dbh, switch_cache_db_handle::io_mutex, io_mutex, switch_cache_db_handle::native_handle, switch_cache_db_native_handle_t::odbc_dbh, switch_cache_db_native_handle_t::pgsql_dbh, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, SWITCH_CHANNEL_LOG, switch_core_db_exec(), switch_core_db_free(), SWITCH_CORE_DB_OK, SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_handle_exec(), switch_pgsql_handle_exec, switch_safe_free, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_strdup, switch_stristr(), and switch_cache_db_handle::type.
Referenced by do_trans(), switch_cache_db_execute_sql_chunked(), switch_cache_db_persistant_execute(), switch_cache_db_persistant_execute_trans_full(), and switch_core_sqldb_start().
void switch_cache_db_flush_handles | ( | void | ) |
Definition at line 291 of file switch_core_sqldb.c.
References SQL_CACHE_TIMEOUT, sql_close(), and switch_epoch_time_now().
Referenced by switch_core_session_ctl(), and switch_core_sqldb_stop().
switch_cache_db_handle_type_t switch_cache_db_get_type | ( | switch_cache_db_handle_t * | dbh | ) |
Definition at line 286 of file switch_core_sqldb.c.
Referenced by switch_console_complete(), switch_console_expand_alias(), and switch_console_set_alias().
int switch_cache_db_load_extension | ( | switch_cache_db_handle_t * | dbh, |
const char * | extension | ||
) |
load an external extension to db
[in] | dbh | The handle |
[out] | the | path to the extension |
Definition at line 710 of file switch_core_sqldb.c.
References SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, SWITCH_CHANNEL_LOG, switch_core_db_load_extension(), SWITCH_LOG_DEBUG, SWITCH_LOG_ERROR, and switch_log_printf().
switch_status_t switch_cache_db_persistant_execute | ( | switch_cache_db_handle_t * | dbh, |
const char * | sql, | ||
uint32_t | retries | ||
) |
Definition at line 801 of file switch_core_sqldb.c.
References io_mutex, switch_cache_db_execute_sql_real(), SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_safe_free, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_yield.
Referenced by switch_console_set_alias().
switch_status_t switch_cache_db_persistant_execute_trans_full | ( | switch_cache_db_handle_t * | dbh, |
char * | sql, | ||
uint32_t | retries, | ||
const char * | pre_trans_execute, | ||
const char * | post_trans_execute, | ||
const char * | inner_pre_trans_execute, | ||
const char * | inner_post_trans_execute | ||
) |
Definition at line 839 of file switch_core_sqldb.c.
References io_mutex, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, switch_cache_db_execute_sql(), switch_cache_db_execute_sql_real(), SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, SWITCH_LOG_DEBUG, SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_SQLEndTran(), switch_odbc_SQLSetAutoCommitAttr(), SWITCH_ODBC_SUCCESS, switch_pgsql_finish_results, switch_pgsql_SQLEndTran(), switch_pgsql_SQLSetAutoCommitAttr(), SWITCH_PGSQL_SUCCESS, switch_safe_free, switch_snprintfv(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_yield, and zstr.
void switch_cache_db_release_db_handle | ( | switch_cache_db_handle_t ** | dbh | ) |
Returns the handle to the pool, handle is NOT available to other threads until the allocating thread actually terminates.
[in] | The | handle |
Definition at line 297 of file switch_core_sqldb.c.
References SCDB_TYPE_PGSQL, sql_manager, switch_epoch_time_now(), switch_mutex_lock(), switch_mutex_unlock(), and switch_pgsql_flush().
Referenced by sql_in_thread(), switch_cache_db_dismiss_db_handle(), switch_console_complete(), switch_console_expand_alias(), switch_console_list_uuid(), switch_console_set_alias(), switch_core_recovery_flush(), switch_core_recovery_recover(), switch_core_sqldb_start(), switch_sql_queue_manager_push_confirm(), and switch_user_sql_thread().
void switch_cache_db_status | ( | switch_stream_handle_t * | stream | ) |
Provides some feedback as to the status of the db connection pool.
[in] | stream | stream for status |
Definition at line 3716 of file switch_core_sqldb.c.
References CACHE_DB_LEN, switch_cache_db_handle::creator, dbh, switch_cache_db_handle::last_used, switch_cache_db_handle::last_user, memset(), switch_cache_db_handle::mutex, switch_cache_db_handle::name, switch_cache_db_handle::next, sql_manager, switch_cache_db_type_name(), switch_epoch_time_now(), SWITCH_FALSE, switch_mutex_lock(), switch_mutex_trylock(), switch_mutex_unlock(), SWITCH_STATUS_SUCCESS, SWITCH_TRUE, switch_cache_db_handle::total_used_count, switch_cache_db_handle::type, and switch_cache_db_handle::use_count.
switch_bool_t switch_cache_db_test_reactive | ( | switch_cache_db_handle_t * | dbh, |
const char * | test_sql, | ||
const char * | drop_sql, | ||
const char * | reactive_sql | ||
) |
Performs test_sql and if it fails performs drop_sql and reactive_sql.
If auto-clear-sql is disabled, then this function will do nothing and it is assumed that the queries are not needed. If auto-create-schemas is disabled, then just test_sql is executed, but drop_sql and reactive_sql are not.
Otherwise, test_sql gets executed. If that succeeds, then there is nothing to do. Otherwise drop_sql is executed (its result is ignored) and then finally reactive_sql is executed.
Definition at line 1299 of file switch_core_sqldb.c.
References io_mutex, runtime, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, SCF_AUTO_SCHEMAS, SCF_CLEAR_SQL, switch_assert, switch_cache_db_execute_sql(), SWITCH_CHANNEL_LOG, switch_core_db_exec(), switch_core_db_free(), SWITCH_FALSE, SWITCH_LOG_DEBUG, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_handle_exec(), SWITCH_ODBC_SUCCESS, switch_pgsql_handle_exec, SWITCH_PGSQL_SUCCESS, SWITCH_STATUS_SUCCESS, switch_test_flag, and SWITCH_TRUE.
Referenced by switch_core_sqldb_start().
switch_status_t switch_core_add_registration | ( | const char * | user, |
const char * | realm, | ||
const char * | token, | ||
const char * | url, | ||
uint32_t | expires, | ||
const char * | network_ip, | ||
const char * | network_port, | ||
const char * | network_proto, | ||
const char * | metadata | ||
) |
Add user registration.
[in] | user | |
[in] | realm | |
[in] | token | |
[in] | url | - a freeswitch dial string |
[in] | expires | |
[in] | network_ip | |
[in] | network_port | |
[in] | network_proto | - one of tls, tcp, udp |
[in] | metadata | - generic metadata supplied by module |
[out] | err | - Error if it exists |
Definition at line 3244 of file switch_core_sqldb.c.
References switch_runtime::multiple_registrations, runtime, SCF_USE_SQL, db_job::sql, sql_manager, switch_core_get_switchname(), SWITCH_FALSE, switch_mprintf(), switch_sql_queue_manager_push(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_str_nil, switch_test_flag, and zstr.
switch_cache_db_handle_type_t switch_core_dbtype | ( | void | ) |
Definition at line 3129 of file switch_core_sqldb.c.
References SCDB_TYPE_CORE_DB, sql_manager, switch_mutex_lock(), and switch_mutex_unlock().
Referenced by switch_console_set_complete().
switch_status_t switch_core_del_registration | ( | const char * | user, |
const char * | realm, | ||
const char * | token | ||
) |
Delete user registration.
[in] | user | |
[in] | realm | |
[in] | token | |
[out] | err | - Error if it exists |
Definition at line 3299 of file switch_core_sqldb.c.
References switch_runtime::multiple_registrations, runtime, SCF_USE_SQL, db_job::sql, sql_manager, switch_core_get_switchname(), SWITCH_FALSE, switch_mprintf(), switch_sql_queue_manager_push(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_test_flag, and zstr.
switch_status_t switch_core_expire_registration | ( | int | force | ) |
Expire user registrations.
[in] | force | delete all registrations |
[out] | err | - Error if it exists |
Definition at line 3320 of file switch_core_sqldb.c.
References runtime, SCF_USE_SQL, db_job::sql, sql_manager, switch_core_get_switchname(), switch_epoch_time_now(), SWITCH_FALSE, switch_mprintf(), switch_sql_queue_manager_push(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_test_flag.
Referenced by switch_core_sql_db_thread().
void switch_core_recovery_flush | ( | const char * | technology, |
const char * | profile_name | ||
) |
Definition at line 2915 of file switch_core_sqldb.c.
References dbh, db_job::sql, switch_cache_db_execute_sql(), switch_cache_db_release_db_handle(), SWITCH_CHANNEL_LOG, switch_core_db_handle, SWITCH_LOG_ERROR, switch_log_printf(), SWITCH_LOG_WARNING, switch_mprintf(), switch_safe_free, SWITCH_STATUS_SUCCESS, and zstr.
Referenced by switch_core_session_ctl().
int switch_core_recovery_recover | ( | const char * | technology, |
const char * | profile_name | ||
) |
Definition at line 3049 of file switch_core_sqldb.c.
References dbh, recover_callback(), db_job::sql, sql_manager, switch_cache_db_execute_sql(), switch_cache_db_execute_sql_callback(), switch_cache_db_release_db_handle(), SWITCH_CHANNEL_LOG, switch_core_db_handle, switch_core_get_uuid(), SWITCH_LOG_ERROR, switch_log_printf(), switch_mprintf(), switch_safe_free, SWITCH_STATUS_SUCCESS, and zstr.
Referenced by switch_core_session_ctl().
void switch_core_recovery_track | ( | switch_core_session_t * | session | ) |
Definition at line 3194 of file switch_core_sqldb.c.
References CF_ANSWERED, CF_RECOVERING, CF_TRACKABLE, CF_TRACKED, CS_SOFT_EXECUTE, db_job::sql, sql_manager, switch_channel_get_state(), switch_channel_get_variable_dup(), switch_channel_set_flag, switch_channel_test_flag(), switch_core_get_switchname(), switch_core_get_uuid(), switch_core_session_get_channel(), switch_core_session_get_uuid(), SWITCH_FALSE, switch_ivr_generate_xml_cdr(), switch_mprintf(), switch_safe_free, switch_sql_queue_manager_push(), SWITCH_STATUS_SUCCESS, switch_str_nil, switch_xml_free(), and switch_xml_toxml_nolock().
Referenced by switch_channel_clear_flag(), switch_channel_perform_mark_answered(), switch_core_media_activate_rtp(), and switch_core_session_perform_receive_message().
void switch_core_recovery_untrack | ( | switch_core_session_t * | session, |
switch_bool_t | force | ||
) |
Definition at line 3156 of file switch_core_sqldb.c.
References CF_ANSWERED, CF_RECOVERING, CF_TRACKABLE, CF_TRACKED, CS_SOFT_EXECUTE, db_job::sql, sql_manager, switch_channel_clear_flag(), switch_channel_get_state(), switch_channel_test_flag(), switch_core_get_uuid(), switch_core_session_get_channel(), switch_core_session_get_uuid(), SWITCH_FALSE, switch_mprintf(), and switch_sql_queue_manager_push().
Referenced by switch_core_standard_on_hangup().
|
static |
Definition at line 1379 of file switch_core_sqldb.c.
References runtime, SCF_USE_SQL, SQL_CACHE_TIMEOUT, sql_close(), sql_manager, SQL_REG_TIMEOUT, switch_core_expire_registration(), switch_epoch_time_now(), switch_test_flag, and switch_yield.
Referenced by switch_core_sqldb_start().
void switch_core_sql_exec | ( | const char * | sql | ) |
Definition at line 3142 of file switch_core_sqldb.c.
References runtime, SCF_USE_SQL, sql_manager, switch_sql_queue_manager_push(), switch_test_flag, and SWITCH_TRUE.
Referenced by switch_console_set_complete().
switch_status_t switch_core_sqldb_start | ( | switch_memory_pool_t * | pool, |
switch_bool_t | manage | ||
) |
Definition at line 3344 of file switch_core_sqldb.c.
References basic_calls_sql, core_event_handler(), create_alias_sql, create_calls_sql, create_channels_sql, create_complete_sql, create_interfaces_sql, create_nat_sql, create_registrations_sql, create_tasks_sql, DBTYPE_DEFAULT, detailed_calls_sql, manage, switch_runtime::odbc_dbtype, switch_runtime::odbc_dsn, pool, recovery_sql, runtime, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, SCF_CLEAR_SQL, SCF_CORE_NON_SQLITE_DB_REQ, SCF_USE_SQL, skip(), db_job::sql, sql_manager, switch_cache_db_create_schema(), switch_cache_db_execute_sql(), switch_cache_db_execute_sql_real(), switch_cache_db_release_db_handle(), switch_cache_db_test_reactive(), SWITCH_CHANNEL_LOG, switch_clear_flag, switch_core_db_handle, switch_core_get_hostname(), switch_core_get_switchname(), switch_core_sql_db_thread(), switch_core_sqldb_start_thread(), SWITCH_EVENT_ADD_SCHEDULE, SWITCH_EVENT_ALL, switch_event_bind(), SWITCH_EVENT_CALL_SECURE, SWITCH_EVENT_CALL_UPDATE, SWITCH_EVENT_CHANNEL_ANSWER, SWITCH_EVENT_CHANNEL_BRIDGE, SWITCH_EVENT_CHANNEL_CALLSTATE, SWITCH_EVENT_CHANNEL_CREATE, SWITCH_EVENT_CHANNEL_DESTROY, SWITCH_EVENT_CHANNEL_EXECUTE, SWITCH_EVENT_CHANNEL_HOLD, SWITCH_EVENT_CHANNEL_ORIGINATE, SWITCH_EVENT_CHANNEL_PROGRESS_MEDIA, SWITCH_EVENT_CHANNEL_STATE, SWITCH_EVENT_CHANNEL_UNBRIDGE, SWITCH_EVENT_CHANNEL_UNHOLD, SWITCH_EVENT_CHANNEL_UUID, SWITCH_EVENT_CODEC, SWITCH_EVENT_DEL_SCHEDULE, SWITCH_EVENT_EXE_SCHEDULE, SWITCH_EVENT_LOG, SWITCH_EVENT_MODULE_LOAD, SWITCH_EVENT_MODULE_UNLOAD, SWITCH_EVENT_NAT, SWITCH_EVENT_RE_SCHEDULE, SWITCH_EVENT_SHUTDOWN, SWITCH_EVENT_SUBCLASS_ANY, SWITCH_LOG_CRIT, SWITCH_LOG_ERROR, SWITCH_LOG_INFO, switch_log_printf(), SWITCH_LOG_WARNING, switch_mutex_init(), SWITCH_MUTEX_NESTED, switch_odbc_SQLEndTran(), switch_odbc_SQLSetAutoCommitAttr(), SWITCH_ODBC_SUCCESS, switch_pgsql_finish_results, switch_pgsql_SQLEndTran(), switch_pgsql_SQLSetAutoCommitAttr(), SWITCH_PGSQL_SUCCESS, SWITCH_PRI_REALTIME, switch_safe_free, switch_snprintfv(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_string_replace(), switch_stristr(), switch_test_flag, switch_thread_create(), SWITCH_THREAD_STACKSIZE, switch_threadattr_create(), switch_threadattr_priority_set(), and switch_threadattr_stacksize_set().
Referenced by switch_core_init().
|
static |
Definition at line 3666 of file switch_core_sqldb.c.
References switch_runtime::core_db_inner_post_trans_execute, switch_runtime::core_db_inner_pre_trans_execute, switch_runtime::core_db_post_trans_execute, switch_runtime::core_db_pre_trans_execute, switch_runtime::dbname, switch_runtime::odbc_dsn, runtime, sql_manager, SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, switch_log_printf(), SWITCH_MAX_TRANS, switch_mutex_lock(), switch_mutex_unlock(), switch_sql_queue_manager_init_name(), switch_sql_queue_manager_start(), and zstr.
Referenced by switch_core_sqldb_start().
void switch_core_sqldb_stop | ( | void | ) |
Definition at line 3699 of file switch_core_sqldb.c.
References core_event_handler(), sql_close(), sql_manager, switch_cache_db_flush_handles(), switch_core_sqldb_stop_thread(), switch_event_unbind_callback(), and switch_thread_join().
Referenced by switch_core_destroy().
|
static |
Definition at line 3652 of file switch_core_sqldb.c.
References sql_manager, SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), and switch_sql_queue_manager_destroy().
Referenced by switch_core_sqldb_stop().
char* switch_sql_concat | ( | void | ) |
This routine is a variant of the "sprintf()" from the standard C library. The resulting string is written into memory obtained from malloc() so that there is never a possiblity of buffer overflow. This routine also implement some additional formatting options that are useful for constructing SQL statements.
The strings returned by this routine should be freed by calling switch_core_db_free().
All of the usual printf formatting options apply. In addition, there is a "%q" option. q works like s in that it substitutes a null-terminated string from the argument list. But q also doubles every '\'' character. q is designed for use inside a string literal. By doubling each '\'' character it escapes that character and allows it to be inserted into the string.
For example, so some string variable contains text as follows:
char *zText = "It's a happy day!";
We can use this text in an SQL statement as follows:
char *z = switch_core_db_mprintf("INSERT INTO TABLES('%q')", zText); switch_core_db_exec(db, z, callback1, 0, 0); switch_core_db_free(z);
Because the q format string is used, the '\'' character in zText is escaped and the SQL generated is as follows:
INSERT INTO table1 VALUES('It''s a happy day!')
This is correct. Had we used s instead of q, the generated SQL would have looked like this:
INSERT INTO table1 VALUES('It's a happy day!');
This second example is an SQL syntax error. As a general rule you should always use q instead of s when inserting text into a string literal.
Definition at line 3790 of file switch_core_sqldb.c.
References DBTYPE_MSSQL, switch_runtime::odbc_dbtype, and runtime.
switch_status_t switch_sql_queue_manager_destroy | ( | switch_sql_queue_manager_t ** | qmp | ) |
Definition at line 1704 of file switch_core_sqldb.c.
References do_flush(), switch_sql_queue_manager::name, switch_sql_queue_manager::numq, pool, switch_sql_queue_manager::pool, qm, switch_assert, SWITCH_CHANNEL_LOG, switch_core_destroy_memory_pool, SWITCH_LOG_INFO, switch_log_printf(), switch_sql_queue_manager_stop(), and SWITCH_STATUS_SUCCESS.
Referenced by switch_core_sqldb_stop_thread().
void switch_sql_queue_manager_execute_sql_callback | ( | switch_sql_queue_manager_t * | qm, |
const char * | sql, | ||
switch_core_db_callback_func_t | callback, | ||
void * | pdata | ||
) |
Definition at line 1553 of file switch_core_sqldb.c.
References new_job(), and switch_thread_pool_launch_thread().
void switch_sql_queue_manager_execute_sql_callback_err | ( | switch_sql_queue_manager_t * | qm, |
const char * | sql, | ||
switch_core_db_callback_func_t | callback, | ||
switch_core_db_err_callback_func_t | err_callback, | ||
void * | pdata | ||
) |
Definition at line 1563 of file switch_core_sqldb.c.
References new_job(), and switch_thread_pool_launch_thread().
void switch_sql_queue_manager_execute_sql_event_callback | ( | switch_sql_queue_manager_t * | qm, |
const char * | sql, | ||
switch_core_db_event_callback_func_t | callback, | ||
void * | pdata | ||
) |
Definition at line 1574 of file switch_core_sqldb.c.
References new_job(), and switch_thread_pool_launch_thread().
void switch_sql_queue_manager_execute_sql_event_callback_err | ( | switch_sql_queue_manager_t * | qm, |
const char * | sql, | ||
switch_core_db_event_callback_func_t | callback, | ||
switch_core_db_err_callback_func_t | err_callback, | ||
void * | pdata | ||
) |
Definition at line 1584 of file switch_core_sqldb.c.
References new_job(), and switch_thread_pool_launch_thread().
switch_status_t switch_sql_queue_manager_init_name | ( | const char * | name, |
switch_sql_queue_manager_t ** | qmp, | ||
uint32_t | numq, | ||
const char * | dsn, | ||
uint32_t | max_trans, | ||
const char * | pre_trans_execute, | ||
const char * | post_trans_execute, | ||
const char * | inner_pre_trans_execute, | ||
const char * | inner_post_trans_execute | ||
) |
Definition at line 1847 of file switch_core_sqldb.c.
References switch_sql_queue_manager::cond, switch_sql_queue_manager::cond2_mutex, switch_sql_queue_manager::cond_mutex, switch_sql_queue_manager::dsn, switch_sql_queue_manager::inner_post_trans_execute, switch_sql_queue_manager::inner_pre_trans_execute, switch_sql_queue_manager::max_trans, switch_sql_queue_manager::mutex, switch_sql_queue_manager::name, switch_sql_queue_manager::numq, pool, switch_sql_queue_manager::pool, switch_sql_queue_manager::post_trans_execute, switch_sql_queue_manager::pre_trans_execute, switch_sql_queue_manager::pre_written, qm, switch_sql_queue_manager::sql_queue, switch_core_alloc, switch_core_new_memory_pool, switch_core_strdup, switch_mutex_init(), SWITCH_MUTEX_NESTED, switch_queue_create(), SWITCH_SQL_QUEUE_LEN, SWITCH_STATUS_SUCCESS, switch_thread_cond_create(), and switch_sql_queue_manager::written.
Referenced by switch_core_sqldb_start_thread().
void switch_sql_queue_manager_pause | ( | switch_sql_queue_manager_t * | qm, |
switch_bool_t | flush | ||
) |
Definition at line 1626 of file switch_core_sqldb.c.
References do_flush(), switch_mutex_lock(), and switch_mutex_unlock().
switch_status_t switch_sql_queue_manager_push | ( | switch_sql_queue_manager_t * | qm, |
const char * | sql, | ||
uint32_t | pos, | ||
switch_bool_t | dup | ||
) |
Definition at line 1731 of file switch_core_sqldb.c.
References qm_wake(), sql_manager, SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_queue_trypush(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_yield.
Referenced by core_event_handler(), switch_core_add_registration(), switch_core_del_registration(), switch_core_expire_registration(), switch_core_recovery_track(), switch_core_recovery_untrack(), and switch_core_sql_exec().
switch_status_t switch_sql_queue_manager_push_confirm | ( | switch_sql_queue_manager_t * | qm, |
const char * | sql, | ||
uint32_t | pos, | ||
switch_bool_t | dup | ||
) |
Definition at line 1773 of file switch_core_sqldb.c.
References dbh, qm_wake(), sql_manager, switch_cache_db_execute_sql(), switch_cache_db_get_db_handle_dsn, switch_cache_db_release_db_handle(), SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_queue_push(), switch_sql_queue_manager_size(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_yield.
void switch_sql_queue_manager_resume | ( | switch_sql_queue_manager_t * | qm | ) |
Definition at line 1616 of file switch_core_sqldb.c.
References qm_wake(), switch_mutex_lock(), and switch_mutex_unlock().
int switch_sql_queue_manager_size | ( | switch_sql_queue_manager_t * | qm, |
uint32_t | index | ||
) |
Definition at line 1642 of file switch_core_sqldb.c.
References switch_mutex_lock(), switch_mutex_unlock(), and switch_queue_size().
Referenced by switch_sql_queue_manager_push_confirm().
switch_status_t switch_sql_queue_manager_start | ( | switch_sql_queue_manager_t * | qm | ) |
Definition at line 1688 of file switch_core_sqldb.c.
References apr_threadattr_t::pool, SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, switch_log_printf(), SWITCH_PRI_NORMAL, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_thread_create(), SWITCH_THREAD_STACKSIZE, switch_threadattr_create(), switch_threadattr_priority_set(), switch_threadattr_stacksize_set(), and switch_user_sql_thread().
Referenced by switch_core_sqldb_start_thread().
switch_status_t switch_sql_queue_manager_stop | ( | switch_sql_queue_manager_t * | qm | ) |
Definition at line 1655 of file switch_core_sqldb.c.
References qm_wake(), SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, switch_log_printf(), switch_queue_interrupt_all(), switch_queue_push(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_thread_join(), and switch_yield.
Referenced by switch_sql_queue_manager_destroy().
|
static |
Definition at line 2045 of file switch_core_sqldb.c.
References switch_sql_queue_manager::cond, switch_sql_queue_manager::cond2_mutex, switch_sql_queue_manager::cond_mutex, do_flush(), do_trans(), switch_sql_queue_manager::dsn, switch_sql_queue_manager::event_db, switch_sql_queue_manager::max_trans, switch_sql_queue_manager::name, switch_sql_queue_manager::numq, switch_sql_queue_manager::paused, qm, qm_ttl(), runtime, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, SCF_DEBUG_SQL, sql_manager, switch_sql_queue_manager::sql_queue, switch_cache_db_execute_sql(), switch_cache_db_get_db_handle_dsn, switch_cache_db_release_db_handle(), SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, switch_log_printf(), SWITCH_LOG_WARNING, switch_mutex_lock(), switch_mutex_unlock(), switch_queue_size(), switch_snprintf(), SWITCH_STATUS_SUCCESS, switch_test_flag, switch_thread_cond_wait(), switch_yield, switch_sql_queue_manager::thread_running, and switch_cache_db_handle::type.
Referenced by switch_sql_queue_manager_start().
|
static |
Definition at line 2862 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
|
static |
Definition at line 2674 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
|
static |
Definition at line 2723 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
|
static |
Definition at line 2682 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
|
static |
Definition at line 2658 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
|
static |
Definition at line 2733 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
|
static |
Definition at line 2754 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
|
static |
Definition at line 2763 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
|
static |
Definition at line 2744 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
switch_mutex_t* ctl_mutex |
Definition at line 67 of file switch_core_sqldb.c.
switch_thread_t* db_thread |
Definition at line 62 of file switch_core_sqldb.c.
int db_thread_running |
Definition at line 63 of file switch_core_sqldb.c.
Definition at line 71 of file switch_core_sqldb.c.
Referenced by add_handle(), sql_close(), sql_in_thread(), switch_cache_db_status(), switch_core_recovery_flush(), switch_core_recovery_recover(), and switch_sql_queue_manager_push_confirm().
switch_mutex_t* dbh_mutex |
Definition at line 66 of file switch_core_sqldb.c.
|
static |
Definition at line 2781 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
switch_cache_db_handle_t* handle_pool |
Definition at line 68 of file switch_core_sqldb.c.
switch_mutex_t* io_mutex |
Definition at line 65 of file switch_core_sqldb.c.
Referenced by do_trans(), switch_cache_db_execute_sql(), switch_cache_db_execute_sql2str(), switch_cache_db_execute_sql_callback(), switch_cache_db_execute_sql_callback_err(), switch_cache_db_execute_sql_event_callback(), switch_cache_db_execute_sql_event_callback_err(), switch_cache_db_execute_sql_real(), switch_cache_db_persistant_execute(), switch_cache_db_persistant_execute_trans_full(), and switch_cache_db_test_reactive().
switch_bool_t manage |
Definition at line 64 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
switch_memory_pool_t* memory_pool |
Definition at line 61 of file switch_core_sqldb.c.
int paused |
Definition at line 73 of file switch_core_sqldb.c.
Definition at line 72 of file switch_core_sqldb.c.
Referenced by new_job(), switch_sql_queue_manager_destroy(), switch_sql_queue_manager_init_name(), and switch_user_sql_thread().
|
static |
Definition at line 2852 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
struct { ... } sql_manager |
Referenced by _switch_cache_db_get_db_handle(), _switch_core_db_handle(), add_handle(), core_event_handler(), del_handle(), get_handle(), sql_close(), switch_cache_db_release_db_handle(), switch_cache_db_status(), switch_core_add_registration(), switch_core_dbtype(), switch_core_del_registration(), switch_core_expire_registration(), switch_core_recovery_recover(), switch_core_recovery_track(), switch_core_recovery_untrack(), switch_core_sql_db_thread(), switch_core_sql_exec(), switch_core_sqldb_pause(), switch_core_sqldb_resume(), switch_core_sqldb_start(), switch_core_sqldb_start_thread(), switch_core_sqldb_stop(), switch_core_sqldb_stop_thread(), switch_sql_queue_manager_push(), switch_sql_queue_manager_push_confirm(), and switch_user_sql_thread().
uint32_t total_handles |
Definition at line 69 of file switch_core_sqldb.c.
uint32_t total_used_handles |
Definition at line 70 of file switch_core_sqldb.c.