mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Fix btree.c so that it works with -DSQLITE_THREADSAFE=0 and -DSQLITE_DEBUG=1 (CVS 4387)
FossilOrigin-Name: fee2d7c0e6d34dd19ff5f7631c1743879068c8ce
This commit is contained in:
18
src/btree.c
18
src/btree.c
@@ -9,7 +9,7 @@
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** $Id: btree.c,v 1.421 2007/09/03 15:19:35 drh Exp $
|
||||
** $Id: btree.c,v 1.422 2007/09/03 22:00:39 drh Exp $
|
||||
**
|
||||
** This file implements a external (disk-based) database using BTrees.
|
||||
** See the header comment on "btreeInt.h" for additional information.
|
||||
@@ -1267,11 +1267,13 @@ int sqlite3BtreeOpen(
|
||||
sqlite3_mutex *mutexShared;
|
||||
pBt->nRef = 1;
|
||||
mutexShared = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
|
||||
pBt->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);
|
||||
if( pBt->mutex==0 ){
|
||||
rc = SQLITE_NOMEM;
|
||||
pSqlite->mallocFailed = 0;
|
||||
goto btree_open_out;
|
||||
if( SQLITE_THREADSAFE ){
|
||||
pBt->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);
|
||||
if( pBt->mutex==0 ){
|
||||
rc = SQLITE_NOMEM;
|
||||
pSqlite->mallocFailed = 0;
|
||||
goto btree_open_out;
|
||||
}
|
||||
}
|
||||
sqlite3_mutex_enter(mutexShared);
|
||||
pBt->pNext = sqlite3SharedCacheList;
|
||||
@@ -1354,7 +1356,9 @@ static int removeFromSharingList(BtShared *pBt){
|
||||
pList->pNext = pBt->pNext;
|
||||
}
|
||||
}
|
||||
sqlite3_mutex_free(pBt->mutex);
|
||||
if( SQLITE_THREADSAFE ){
|
||||
sqlite3_mutex_free(pBt->mutex);
|
||||
}
|
||||
removed = 1;
|
||||
}
|
||||
sqlite3_mutex_leave(pMaster);
|
||||
|
Reference in New Issue
Block a user