From ef149fb30dae64f1e9690bd5367eb5074810b97f Mon Sep 17 00:00:00 2001 From: mom040267 Date: Mon, 17 Nov 2014 01:33:31 +0000 Subject: [PATCH] default turndb changed to ~/turndb --- README.turnadmin | 4 ++-- README.turnserver | 6 +++--- README.turnutils | 2 +- examples/etc/turnserver.conf | 4 ++-- man/man1/turnadmin.1 | 4 ++-- man/man1/turnserver.1 | 6 +++--- man/man1/turnutils.1 | 2 +- src/apps/relay/dbdrivers/dbd_sqlite.c | 20 ++++++++++++++++++++ src/apps/relay/mainrelay.c | 4 ++-- src/apps/relay/userdb.h | 2 +- 10 files changed, 37 insertions(+), 17 deletions(-) diff --git a/README.turnadmin b/README.turnadmin index 269dfbbb..22d1f70f 100644 --- a/README.turnadmin +++ b/README.turnadmin @@ -80,7 +80,7 @@ Commands: Options with required values: --b, --db, --userdb SQLite user database file name (default - /var/turndb). +-b, --db, --userdb SQLite user database file name (default - ~/turndb). See the same option in the turnserver section. -e, --psql-userdb PostgreSQL user database connection string. See the --psql-userdb option in the turnserver section. @@ -170,7 +170,7 @@ to see the man page. /etc/turnserver.conf -/var/turndb +~/turndb /usr/local/etc/turnserver.conf diff --git a/README.turnserver b/README.turnserver index d35658bc..a2199b28 100644 --- a/README.turnserver +++ b/README.turnserver @@ -81,7 +81,7 @@ Config file settings: User database settings: --b, --db, --userdb SQLite user database file name (default - /var/turndb). +-b, --db, --userdb SQLite user database file name (default - ~/turndb). -e, --psql-userdb User database connection string for PostgreSQL. This database can be used for long-term and short-term @@ -716,7 +716,7 @@ For the user database, the turnserver has the following options: Obviously, only a few users can be set that way, and their credentials are fixed for the turnserver process lifetime. -2) Users can be stored in SQlite DB. The default SQLite database file is /var/turndb. +2) Users can be stored in SQLite DB. The default SQLite database file is ~/turndb. 3) Users can be stored in PostgreSQL database, if the turnserver was compiled with PostgreSQL support. Each time turnserver checks user credentials, it reads the database (asynchronously, @@ -841,7 +841,7 @@ FILES /etc/turnserver.conf -/var/turndb +~/turndb /usr/local/etc/turnserver.conf diff --git a/README.turnutils b/README.turnutils index 42f9359a..8beaf824 100644 --- a/README.turnutils +++ b/README.turnutils @@ -251,7 +251,7 @@ FILES /etc/turnserver.conf -/var/turndb +~/turndb /usr/local/etc/turnserver.conf diff --git a/examples/etc/turnserver.conf b/examples/etc/turnserver.conf index bfef53b7..e853f500 100644 --- a/examples/etc/turnserver.conf +++ b/examples/etc/turnserver.conf @@ -250,9 +250,9 @@ # SQLite database file name. # -# Default file name is /var/turndb +# Default file name is ~/turndb (turndb in the process' home directory). # -#userdb=/var/turndb +#userdb=~/turndb # PostgreSQL database connection string in the case that we are using PostgreSQL # as the user database. diff --git a/man/man1/turnadmin.1 b/man/man1/turnadmin.1 index d92301b9..dd0cf25d 100644 --- a/man/man1/turnadmin.1 +++ b/man/man1/turnadmin.1 @@ -132,7 +132,7 @@ Options with required values: .TP .B \fB\-b\fP, \fB\-\-db\fP, \fB\-\-userdb\fP -SQLite user database file name (default \- /var/turndb). +SQLite user database file name (default \- ~/turndb). See the same option in the \fIturnserver\fP section. .TP .B @@ -261,7 +261,7 @@ to see the man page. /etc/turnserver.conf .PP -/var/turndb +~/turndb .PP /usr/local/etc/turnserver.conf .PP diff --git a/man/man1/turnserver.1 b/man/man1/turnserver.1 index 1833f4a6..bad4a5df 100644 --- a/man/man1/turnserver.1 +++ b/man/man1/turnserver.1 @@ -132,7 +132,7 @@ User database settings: .TP .B \fB\-b\fP, \fB\-\-db\fP, \fB\-\-userdb\fP -SQLite user database file name (default \- /var/turndb). +SQLite user database file name (default \- ~/turndb). .TP .B \fB\-e\fP, \fB\-\-psql\-userdb\fP @@ -971,7 +971,7 @@ Users can be set in the command line, with multiple \fB\-u\fP or \fB\-\-user\fP Obviously, only a few users can be set that way, and their credentials are fixed for the \fIturnserver\fP process lifetime. .IP 2) 4 -Users can be stored in SQlite DB. The default SQLite database file is /var/turndb. +Users can be stored in SQLite DB. The default SQLite database file is ~/turndb. .IP 3) 4 Users can be stored in PostgreSQL database, if the \fIturnserver\fP was compiled with PostgreSQL support. Each time \fIturnserver\fP checks user credentials, it reads the database (asynchronously, @@ -1096,7 +1096,7 @@ it would affect the performance. /etc/turnserver.conf .PP -/var/turndb +~/turndb .PP /usr/local/etc/turnserver.conf .PP diff --git a/man/man1/turnutils.1 b/man/man1/turnutils.1 index 8b405f1e..6df707ae 100644 --- a/man/man1/turnutils.1 +++ b/man/man1/turnutils.1 @@ -374,7 +374,7 @@ to see the man page. /etc/turnserver.conf .PP -/var/turndb +~/turndb .PP /usr/local/etc/turnserver.conf .PP diff --git a/src/apps/relay/dbdrivers/dbd_sqlite.c b/src/apps/relay/dbdrivers/dbd_sqlite.c index 6a53df59..fa4b6cb0 100644 --- a/src/apps/relay/dbdrivers/dbd_sqlite.c +++ b/src/apps/relay/dbdrivers/dbd_sqlite.c @@ -36,6 +36,26 @@ /////////////////////////////////////////////////////////////////////////////////////////////////////////// +static int sqlite_init_multithreaded(void) { + + sqlite3_shutdown(); + + if (sqlite3_threadsafe() > 0) { + int retCode = sqlite3_config(SQLITE_CONFIG_SERIALIZED); + if (retCode == SQLITE_OK) { + TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Can now use sqlite on multiple threads, using the same connection\n"); + } else { + TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "setting sqlite thread safe mode to serialized failed!!! return code: %d\n", retCode); + return -1; + } + } else { + TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Your SQLite database is not compiled to be threadsafe.\n"); + return -1; + } + + return 0; +} + #if 0 static int donot_print_connection_success = 0; diff --git a/src/apps/relay/mainrelay.c b/src/apps/relay/mainrelay.c index f294a932..77aca642 100644 --- a/src/apps/relay/mainrelay.c +++ b/src/apps/relay/mainrelay.c @@ -412,7 +412,7 @@ static char Usage[] = "Usage: turnserver [options]\n" " Total bytes-per-second bandwidth the TURN server is allowed to allocate\n" " for the sessions, combined (input and output network streams are treated separately).\n" " -c Configuration file name (default - turnserver.conf).\n" -" -b, , --db, --userdb SQLite database file name (default - "DEFAULT_USERDB_FILE").\n" +" -b, , --db, --userdb SQLite database file name (default - ~/turndb).\n" #if !defined(TURN_NO_PQ) " -e, --psql-userdb, --sql-userdb PostgreSQL database connection string, if used (default - empty, no PostreSQL DB used).\n" " This database can be used for long-term and short-term credentials mechanisms,\n" @@ -584,7 +584,7 @@ static char AdminUsage[] = "Usage: turnadmin [command] [options]\n" " -g, --set-realm-option Set realm params: max-bps, total-quota, user-quota.\n" " -G, --list-realm-options List realm params.\n" "\nOptions with mandatory values:\n\n" - " -b, --db, --userdb SQLite database file, default value is "DEFAULT_USERDB_FILE".\n" + " -b, --db, --userdb SQLite database file, default value is ~/turndb.\n" #if !defined(TURN_NO_PQ) " -e, --psql-userdb, --sql-userdb PostgreSQL user database connection string, if PostgreSQL DB is used.\n" #endif diff --git a/src/apps/relay/userdb.h b/src/apps/relay/userdb.h index 17f3c56f..dc4890fc 100644 --- a/src/apps/relay/userdb.h +++ b/src/apps/relay/userdb.h @@ -48,7 +48,7 @@ extern "C" { //////////// Defines ////////////////////////////// -#define DEFAULT_USERDB_FILE ("/var/turndb") +#define DEFAULT_USERDB_FILE ("~/turndb") #define AUTH_SECRET_SIZE (512)