aboutsummaryrefslogtreecommitdiff
path: root/src/btmutex.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2011-04-05 19:27:41 +0000
committerdrh <drh@noemail.net>2011-04-05 19:27:41 +0000
commit1a86f50d85bdce2d8e766ba2f45a458b9952661b (patch)
treedf70e4f52ac1ebac5d413e591c8ffa81322f37e4 /src/btmutex.c
parentd3ef5ae05f75fd070be6480e47d45645b8f3d135 (diff)
downloadsqlite-1a86f50d85bdce2d8e766ba2f45a458b9952661b.tar.gz
sqlite-1a86f50d85bdce2d8e766ba2f45a458b9952661b.zip
Simplifications to the sqlite3BtreeEnterAll() and LeaveAll() routines.
Just have them call BtreeEnter and BtreeLeave() repeatedly rather than trying to be clever. FossilOrigin-Name: 51039b3578f948c23a810d176e81fa51a278fb28
Diffstat (limited to 'src/btmutex.c')
-rw-r--r--src/btmutex.c31
1 files changed, 3 insertions, 28 deletions
diff --git a/src/btmutex.c b/src/btmutex.c
index 1de9db07e..ffe124fdd 100644
--- a/src/btmutex.c
+++ b/src/btmutex.c
@@ -186,30 +186,11 @@ void sqlite3BtreeLeaveCursor(BtCursor *pCur){
*/
void sqlite3BtreeEnterAll(sqlite3 *db){
int i;
- Btree *p, *pLater;
+ Btree *p;
assert( sqlite3_mutex_held(db->mutex) );
for(i=0; i<db->nDb; i++){
p = db->aDb[i].pBt;
- assert( !p || (p->locked==0 && p->sharable) || p->pBt->db==p->db );
- if( p && p->sharable ){
- p->wantToLock++;
- if( !p->locked ){
- assert( p->wantToLock==1 );
- while( p->pPrev ) p = p->pPrev;
- /* Reason for ALWAYS: There must be at least one unlocked Btree in
- ** the chain. Otherwise the !p->locked test above would have failed */
- while( p->locked && ALWAYS(p->pNext) ) p = p->pNext;
- for(pLater = p->pNext; pLater; pLater=pLater->pNext){
- if( pLater->locked ){
- unlockBtreeMutex(pLater);
- }
- }
- while( p ){
- lockBtreeMutex(p);
- p = p->pNext;
- }
- }
- }
+ if( p ) sqlite3BtreeEnter(p);
}
}
void sqlite3BtreeLeaveAll(sqlite3 *db){
@@ -218,13 +199,7 @@ void sqlite3BtreeLeaveAll(sqlite3 *db){
assert( sqlite3_mutex_held(db->mutex) );
for(i=0; i<db->nDb; i++){
p = db->aDb[i].pBt;
- if( p && p->sharable ){
- assert( p->wantToLock>0 );
- p->wantToLock--;
- if( p->wantToLock==0 ){
- unlockBtreeMutex(p);
- }
- }
+ if( p ) sqlite3BtreeLeave(p);
}
}