mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-14 00:22:38 +03:00
Add the SQLITE_OPEN_NOMUTEX flag. Used for opening connections that are not protected by an internal mutex. (CVS 5387)
FossilOrigin-Name: 7e58b78712420b3bd4320192a58d89eb71eecc9c
This commit is contained in:
14
src/main.c
14
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)) ){
|
||||
|
||||
Reference in New Issue
Block a user