1
0
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:
drh
2007-09-03 22:00:39 +00:00
parent 3f3b635451
commit 3285db26e4
4 changed files with 20 additions and 23 deletions

View File

@@ -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);