mirror of
https://github.com/coturn/coturn.git
synced 2025-10-27 04:51:28 +01:00
Refactor code
This commit is contained in:
parent
34e18533cf
commit
2d12ad4f29
@ -95,7 +95,7 @@ static void sqlite_unlock(int write)
|
|||||||
|
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
static int _sqlite_init_multithreaded(void) {
|
static int sqlite_init_multithreaded(void) {
|
||||||
|
|
||||||
#if defined(SQLITE_CONFIG_MULTITHREAD)
|
#if defined(SQLITE_CONFIG_MULTITHREAD)
|
||||||
if (sqlite3_threadsafe() > 0) {
|
if (sqlite3_threadsafe() > 0) {
|
||||||
@ -116,10 +116,6 @@ static int _sqlite_init_multithreaded(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sqlite_init_multithreaded(void) {
|
|
||||||
(void) _sqlite_init_multithreaded();
|
|
||||||
}
|
|
||||||
|
|
||||||
static int donot_print_connection_success = 0;
|
static int donot_print_connection_success = 0;
|
||||||
|
|
||||||
static void fix_user_directory(char *dir0) {
|
static void fix_user_directory(char *dir0) {
|
||||||
@ -175,16 +171,15 @@ static void init_sqlite_database(sqlite3 *sqliteconnection) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_once_t sqlite_init_once = PTHREAD_ONCE_INIT;
|
|
||||||
|
|
||||||
static sqlite3 * get_sqlite_connection(void) {
|
static sqlite3 * get_sqlite_connection(void) {
|
||||||
|
static pthread_once_t sqlite_init_once = PTHREAD_ONCE_INIT;
|
||||||
|
|
||||||
persistent_users_db_t *pud = get_persistent_users_db();
|
persistent_users_db_t *pud = get_persistent_users_db();
|
||||||
|
|
||||||
sqlite3 *sqliteconnection = (sqlite3 *)pthread_getspecific(connection_key);
|
sqlite3 *sqliteconnection = (sqlite3 *)pthread_getspecific(connection_key);
|
||||||
if(!sqliteconnection) {
|
if(!sqliteconnection) {
|
||||||
fix_user_directory(pud->userdb);
|
fix_user_directory(pud->userdb);
|
||||||
(void) pthread_once(&sqlite_init_once, sqlite_init_multithreaded);
|
(void) pthread_once(&sqlite_init_once, (void (*)(void))sqlite_init_multithreaded);
|
||||||
int rc = sqlite3_open(pud->userdb, &sqliteconnection);
|
int rc = sqlite3_open(pud->userdb, &sqliteconnection);
|
||||||
if(!sqliteconnection || (rc != SQLITE_OK)) {
|
if(!sqliteconnection || (rc != SQLITE_OK)) {
|
||||||
const char* errmsg = sqlite3_errmsg(sqliteconnection);
|
const char* errmsg = sqlite3_errmsg(sqliteconnection);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user