提交 174ad6ed authored 作者: Anthony Minessale's avatar Anthony Minessale

sip reg

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1433 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 64c80bd8
...@@ -758,10 +758,28 @@ SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_write_codec(switch_core ...@@ -758,10 +758,28 @@ SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_write_codec(switch_core
/*! /*!
\brief Open a core db (SQLite) file \brief Open a core db (SQLite) file
\param filename the path to the db file to open \param filename the path to the db file to open
\return \return the db handle
*/ */
SWITCH_DECLARE(switch_core_db_t *) switch_core_db_open_file(char *filename); SWITCH_DECLARE(switch_core_db_t *) switch_core_db_open_file(char *filename);
/*!
\brief Execute a sql stmt until it is accepted
\param db the db handle
\param sql the sql to execute
\param retries the number of retries to use
\return SWITCH_STATUS_SUCCESS if successful
*/
SWITCH_DECLARE(switch_status_t) switch_core_db_persistant_execute(switch_core_db_t *db, char *sql, uint32_t retries);
/*!
\brief perform a test query then perform a reactive query if the first one fails
\param db the db handle
\param test_sql the test sql
\param reactive_sql the reactive sql
*/
SWITCH_DECLARE(void) switch_core_db_test_reactive(switch_core_db_t *db, char *test_sql, char *reactive_sql);
#define SWITCH_CORE_DB "core" #define SWITCH_CORE_DB "core"
/*! /*!
\brief Open the default system database \brief Open the default system database
......
...@@ -135,8 +135,9 @@ SWITCH_DECLARE(switch_core_db_t *) switch_core_db_open_file(char *filename) ...@@ -135,8 +135,9 @@ SWITCH_DECLARE(switch_core_db_t *) switch_core_db_open_file(char *filename)
return db; return db;
} }
#if 0
static void check_table_exists(switch_core_db_t *db, char *test_sql, char *create_sql) { SWITCH_DECLARE(void) switch_core_db_test_reactive(switch_core_db_t *db, char *test_sql, char *reactive_sql)
{
char *errmsg; char *errmsg;
if(db) { if(db) {
...@@ -155,13 +156,13 @@ static void check_table_exists(switch_core_db_t *db, char *test_sql, char *creat ...@@ -155,13 +156,13 @@ static void check_table_exists(switch_core_db_t *db, char *test_sql, char *creat
errmsg = NULL; errmsg = NULL;
switch_core_db_exec( switch_core_db_exec(
db, db,
create_sql, reactive_sql,
NULL, NULL,
NULL, NULL,
&errmsg &errmsg
); );
if (errmsg) { if (errmsg) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL ERR [%s]\n[%s]\n", errmsg, create_sql); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL ERR [%s]\n[%s]\n", errmsg, reactive_sql);
switch_core_db_free(errmsg); switch_core_db_free(errmsg);
errmsg = NULL; errmsg = NULL;
} }
...@@ -170,7 +171,7 @@ static void check_table_exists(switch_core_db_t *db, char *test_sql, char *creat ...@@ -170,7 +171,7 @@ static void check_table_exists(switch_core_db_t *db, char *test_sql, char *creat
} }
} }
#endif
SWITCH_DECLARE(switch_status_t) switch_core_set_console(char *console) SWITCH_DECLARE(switch_status_t) switch_core_set_console(char *console)
...@@ -2499,7 +2500,7 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(char ...@@ -2499,7 +2500,7 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(char
return switch_core_session_request(endpoint_interface, pool); return switch_core_session_request(endpoint_interface, pool);
} }
static switch_status_t switch_core_sql_persistant_execute(switch_core_db_t *db, char *sql, uint32_t retries) SWITCH_DECLARE(switch_status_t) switch_core_db_persistant_execute(switch_core_db_t *db, char *sql, uint32_t retries)
{ {
char *errmsg; char *errmsg;
switch_status_t status = SWITCH_STATUS_FALSE; switch_status_t status = SWITCH_STATUS_FALSE;
...@@ -2513,7 +2514,7 @@ static switch_status_t switch_core_sql_persistant_execute(switch_core_db_t *db, ...@@ -2513,7 +2514,7 @@ static switch_status_t switch_core_sql_persistant_execute(switch_core_db_t *db,
&errmsg &errmsg
); );
if (errmsg) { if (errmsg) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR [%s]\n", errmsg); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR\n[%s]\n[%s]\n", sql,errmsg);
switch_core_db_free(errmsg); switch_core_db_free(errmsg);
switch_yield(100000); switch_yield(100000);
retries--; retries--;
...@@ -2547,7 +2548,7 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread, ...@@ -2547,7 +2548,7 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
work++; work++;
if (itterations == 0) { if (itterations == 0) {
char *isql = "begin transaction CORE1;"; char *isql = "begin transaction CORE1;";
if (switch_core_sql_persistant_execute(runtime.event_db, isql, 25) != SWITCH_STATUS_SUCCESS) { if (switch_core_db_persistant_execute(runtime.event_db, isql, 25) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL exec error! [%s]\n", isql); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL exec error! [%s]\n", isql);
} else { } else {
trans = 1; trans = 1;
...@@ -2556,7 +2557,7 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread, ...@@ -2556,7 +2557,7 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
itterations++; itterations++;
if (switch_core_sql_persistant_execute(runtime.event_db, sql, 25) != SWITCH_STATUS_SUCCESS) { if (switch_core_db_persistant_execute(runtime.event_db, sql, 25) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL exec error! [%s]\n", sql); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL exec error! [%s]\n", sql);
} }
free(sql); free(sql);
...@@ -2573,7 +2574,7 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread, ...@@ -2573,7 +2574,7 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
if (trans && (itterations == target || diff >= freq)) { if (trans && (itterations == target || diff >= freq)) {
char *sql = "end transaction CORE1"; char *sql = "end transaction CORE1";
work++; work++;
if (switch_core_sql_persistant_execute(runtime.event_db, sql, 25) != SWITCH_STATUS_SUCCESS) { if (switch_core_db_persistant_execute(runtime.event_db, sql, 25) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL exec error! [%s]\n", sql); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL exec error! [%s]\n", sql);
} }
last_commit = switch_time_now(); last_commit = switch_time_now();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论