aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authordanielk1977 <danielk1977@noemail.net>2008-07-10 17:52:49 +0000
committerdanielk1977 <danielk1977@noemail.net>2008-07-10 17:52:49 +0000
commit9a6284c1bba40b606a01356ebe962691e1ce256a (patch)
tree23dc252d6c87353e8b125b02d4ce80d9144b0478 /src/main.c
parent93a960a0a8a537784e4f40db2ad06686618a234e (diff)
downloadsqlite-9a6284c1bba40b606a01356ebe962691e1ce256a.tar.gz
sqlite-9a6284c1bba40b606a01356ebe962691e1ce256a.zip
Add the SQLITE_OPEN_NOMUTEX flag. Used for opening connections that are not protected by an internal mutex. (CVS 5387)
FossilOrigin-Name: 7e58b78712420b3bd4320192a58d89eb71eecc9c
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index c3a89488c..e8c47ac56 100644
--- a/src/main.c
+++ b/src/main.c
@@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
-** $Id: main.c,v 1.473 2008/07/09 13:28:54 drh Exp $
+** $Id: main.c,v 1.474 2008/07/10 17:52:49 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -1247,12 +1247,17 @@ static int openDatabase(
sqlite3 *db;
int rc;
CollSeq *pColl;
+ int isThreadsafe = 1;
#ifndef SQLITE_OMIT_AUTOINIT
rc = sqlite3_initialize();
if( rc ) return rc;
#endif
+ if( flags&SQLITE_OPEN_NOMUTEX ){
+ isThreadsafe = 0;
+ }
+
/* Remove harmful bits from the flags parameter */
flags &= ~( SQLITE_OPEN_DELETEONCLOSE |
SQLITE_OPEN_MAIN_DB |
@@ -1261,13 +1266,14 @@ static int openDatabase(
SQLITE_OPEN_MAIN_JOURNAL |
SQLITE_OPEN_TEMP_JOURNAL |
SQLITE_OPEN_SUBJOURNAL |
- SQLITE_OPEN_MASTER_JOURNAL
+ SQLITE_OPEN_MASTER_JOURNAL |
+ SQLITE_OPEN_NOMUTEX
);
/* Allocate the sqlite data structure */
db = sqlite3MallocZero( sizeof(sqlite3) );
if( db==0 ) goto opendb_out;
- if( sqlite3Config.bFullMutex ){
+ if( sqlite3Config.bFullMutex && isThreadsafe ){
db->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_RECURSIVE);
if( db->mutex==0 ){
sqlite3_free(db);
@@ -1424,7 +1430,7 @@ static int openDatabase(
opendb_out:
if( db ){
- assert( db->mutex!=0 || sqlite3Config.bFullMutex==0 );
+ assert( db->mutex!=0 || isThreadsafe==0 || sqlite3Config.bFullMutex==0 );
sqlite3_mutex_leave(db->mutex);
}
if( SQLITE_NOMEM==(rc = sqlite3_errcode(db)) ){