diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 14 |
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)) ){ |