mirror of
https://github.com/coturn/coturn.git
synced 2025-10-26 04:21:00 +01:00
Revert by hand merge PR825 in favor PR755 more simple solution
This commit is contained in:
parent
b5a597836b
commit
a19bc7c464
@ -45,13 +45,11 @@
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
static pthread_mutex_t rc_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_cond_t rc_cond = PTHREAD_COND_INITIALIZER;
|
||||
|
||||
static int read_threads = 0;
|
||||
static int write_level = 0;
|
||||
static pthread_t write_thread = 0;
|
||||
static int sqlite_initialized = 0;
|
||||
|
||||
static void sqlite_lock(int write)
|
||||
{
|
||||
@ -97,11 +95,7 @@ static void sqlite_unlock(int write)
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
static int sqlite_init_multithreaded(void) {
|
||||
if (sqlite_initialized) {
|
||||
return 0;
|
||||
}
|
||||
sqlite_initialized = 1;
|
||||
static void sqlite_init_multithreaded(void) {
|
||||
|
||||
#if defined(SQLITE_CONFIG_MULTITHREAD)
|
||||
if (sqlite3_threadsafe() > 0) {
|
||||
@ -110,17 +104,17 @@ static int sqlite_init_multithreaded(void) {
|
||||
retCode = sqlite3_config(SQLITE_CONFIG_SERIALIZED);
|
||||
if (retCode != SQLITE_OK) {
|
||||
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "setting sqlite thread safe mode to serialized failed!!! return code: %d\n", retCode);
|
||||
return -1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
sqlite3_initialize();
|
||||
} else {
|
||||
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Your SQLite database is not compiled to be threadsafe.\n");
|
||||
return -1;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
static int donot_print_connection_success = 0;
|
||||
@ -185,7 +179,6 @@ static sqlite3 * get_sqlite_connection(void) {
|
||||
|
||||
sqlite3 *sqliteconnection = (sqlite3 *)pthread_getspecific(connection_key);
|
||||
if(!sqliteconnection) {
|
||||
pthread_mutex_lock(&init_mutex);
|
||||
|
||||
fix_user_directory(pud->userdb);
|
||||
(void) pthread_once(&sqlite_init_once, sqlite_init_multithreaded);
|
||||
@ -208,8 +201,6 @@ static sqlite3 * get_sqlite_connection(void) {
|
||||
if(sqliteconnection) {
|
||||
(void) pthread_setspecific(connection_key, sqliteconnection);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&init_mutex);
|
||||
}
|
||||
return sqliteconnection;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user