aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bitvec.c6
-rw-r--r--src/fault.c22
-rw-r--r--src/hash.c6
-rw-r--r--src/main.c6
-rw-r--r--src/pager.c12
-rw-r--r--src/sqliteInt.h8
-rw-r--r--src/test8.c6
-rw-r--r--src/vdbe.c10
-rw-r--r--src/vdbeaux.c6
9 files changed, 49 insertions, 33 deletions
diff --git a/src/bitvec.c b/src/bitvec.c
index c8b8e200b..90c90662f 100644
--- a/src/bitvec.c
+++ b/src/bitvec.c
@@ -32,7 +32,7 @@
** start of a transaction, and is thus usually less than a few thousand,
** but can be as large as 2 billion for a really big database.
**
-** @(#) $Id: bitvec.c,v 1.4 2008/04/14 01:00:58 drh Exp $
+** @(#) $Id: bitvec.c,v 1.5 2008/05/13 13:27:34 drh Exp $
*/
#include "sqliteInt.h"
@@ -140,9 +140,9 @@ int sqlite3BitvecSet(Bitvec *p, u32 i){
u32 bin = (i-1)/p->iDivisor;
i = (i-1)%p->iDivisor + 1;
if( p->u.apSub[bin]==0 ){
- sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 1);
+ sqlite3FaultBeginBenign(SQLITE_FAULTINJECTOR_MALLOC);
p->u.apSub[bin] = sqlite3BitvecCreate( p->iDivisor );
- sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 0);
+ sqlite3FaultEndBenign(SQLITE_FAULTINJECTOR_MALLOC);
if( p->u.apSub[bin]==0 ) return SQLITE_NOMEM;
}
return sqlite3BitvecSet(p->u.apSub[bin], i);
diff --git a/src/fault.c b/src/fault.c
index d31dd4387..cded2351d 100644
--- a/src/fault.c
+++ b/src/fault.c
@@ -42,7 +42,7 @@ static struct FaultInjector {
int nBenign; /* Number of benign failures seen since last config */
int nFail; /* Number of failures seen since last config */
u8 enable; /* True if enabled */
- u8 benign; /* True if next failure will be benign */
+ i16 benign; /* Positive if next failure will be benign */
} aFault[SQLITE_FAULTINJECTOR_COUNT];
/*
@@ -104,14 +104,26 @@ int sqlite3FaultPending(int id){
** will continue to function normally. So a malloc failure during
** a hash table resize is a benign fault.
*/
-void sqlite3FaultBenign(int id, int enable){
+void sqlite3FaultBeginBenign(int id){
if( id<0 ){
for(id=0; id<SQLITE_FAULTINJECTOR_COUNT; id++){
- aFault[id].benign = enable;
+ aFault[id].benign++;
}
}else{
assert( id>=0 && id<SQLITE_FAULTINJECTOR_COUNT );
- aFault[id].benign = enable;
+ aFault[id].benign++;
+ }
+}
+void sqlite3FaultEndBenign(int id){
+ if( id<0 ){
+ for(id=0; id<SQLITE_FAULTINJECTOR_COUNT; id++){
+ assert( aFault[id].benign>0 );
+ aFault[id].benign--;
+ }
+ }else{
+ assert( id>=0 && id<SQLITE_FAULTINJECTOR_COUNT );
+ assert( aFault[id].benign>0 );
+ aFault[id].benign--;
}
}
@@ -140,7 +152,7 @@ int sqlite3FaultStep(int id){
}
sqlite3Fault();
aFault[id].nFail++;
- if( aFault[id].benign ){
+ if( aFault[id].benign>0 ){
aFault[id].nBenign++;
}
aFault[id].nRepeat--;
diff --git a/src/hash.c b/src/hash.c
index 8b3543527..b8d0af629 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -12,7 +12,7 @@
** This is the implementation of generic hash-tables
** used in SQLite.
**
-** $Id: hash.c,v 1.27 2008/04/02 18:33:08 drh Exp $
+** $Id: hash.c,v 1.28 2008/05/13 13:27:34 drh Exp $
*/
#include "sqliteInt.h"
#include <assert.h>
@@ -233,9 +233,9 @@ static void rehash(Hash *pH, int new_size){
** is benign (since failing to resize a hash table is a performance
** hit only, not a fatal error).
*/
- sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, pH->htsize>0);
+ if( pH->htsize>0 ) sqlite3FaultBeginBenign(SQLITE_FAULTINJECTOR_MALLOC);
new_ht = (struct _ht *)sqlite3MallocZero( new_size*sizeof(struct _ht) );
- sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 0);
+ if( pH->htsize>0 ) sqlite3FaultEndBenign(SQLITE_FAULTINJECTOR_MALLOC);
if( new_ht==0 ) return;
sqlite3_free(pH->ht);
diff --git a/src/main.c b/src/main.c
index 668db1255..9f2ff1b90 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.438 2008/05/05 16:56:35 drh Exp $
+** $Id: main.c,v 1.439 2008/05/13 13:27:34 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -254,7 +254,7 @@ void sqlite3RollbackAll(sqlite3 *db){
int i;
int inTrans = 0;
assert( sqlite3_mutex_held(db->mutex) );
- sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 1);
+ sqlite3FaultBeginBenign(SQLITE_FAULTINJECTOR_MALLOC);
for(i=0; i<db->nDb; i++){
if( db->aDb[i].pBt ){
if( sqlite3BtreeIsInTrans(db->aDb[i].pBt) ){
@@ -265,7 +265,7 @@ void sqlite3RollbackAll(sqlite3 *db){
}
}
sqlite3VtabRollback(db);
- sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 0);
+ sqlite3FaultEndBenign(SQLITE_FAULTINJECTOR_MALLOC);
if( db->flags&SQLITE_InternChanges ){
sqlite3ExpirePreparedStatements(db);
diff --git a/src/pager.c b/src/pager.c
index 58b69cb2d..a8d7b4200 100644
--- a/src/pager.c
+++ b/src/pager.c
@@ -18,7 +18,7 @@
** file simultaneously, or one process from reading the database while
** another is writing.
**
-** @(#) $Id: pager.c,v 1.445 2008/05/13 00:58:18 drh Exp $
+** @(#) $Id: pager.c,v 1.446 2008/05/13 13:27:34 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
@@ -688,9 +688,9 @@ static void pager_resize_hash_table(Pager *pPager, int N){
if( N==pPager->nHash ) return;
#endif
pagerLeave(pPager);
- sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, pPager->aHash!=0);
+ if( pPager->aHash!=0 ) sqlite3FaultBeginBenign(SQLITE_FAULTINJECTOR_MALLOC);
aHash = sqlite3MallocZero( sizeof(aHash[0])*N );
- sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 0);
+ if( pPager->aHash!=0 ) sqlite3FaultEndBenign(SQLITE_FAULTINJECTOR_MALLOC);
pagerEnter(pPager);
if( aHash==0 ){
/* Failure to rehash is not an error. It is only a performance hit. */
@@ -1358,7 +1358,9 @@ static void pager_unlock(Pager *pPager){
static void pagerUnlockAndRollback(Pager *p){
/* assert( p->state>=PAGER_RESERVED || p->journalOpen==0 ); */
if( p->errCode==SQLITE_OK && p->state>=PAGER_RESERVED ){
+ sqlite3FaultBeginBenign(-1);
sqlite3PagerRollback(p);
+ sqlite3FaultEndBenign(-1);
}
pager_unlock(p);
#if 0
@@ -2761,13 +2763,13 @@ int sqlite3PagerClose(Pager *pPager){
#endif
disable_simulated_io_errors();
- sqlite3FaultBenign(-1, 1);
+ sqlite3FaultBeginBenign(-1);
pPager->errCode = 0;
pPager->exclusiveMode = 0;
pager_reset(pPager);
pagerUnlockAndRollback(pPager);
enable_simulated_io_errors();
- sqlite3FaultBenign(-1, 0);
+ sqlite3FaultEndBenign(-1);
PAGERTRACE2("CLOSE %d\n", PAGERID(pPager));
IOTRACE(("CLOSE %p\n", pPager))
if( pPager->journalOpen ){
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index e991b1f93..2e223197a 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
-** @(#) $Id: sqliteInt.h,v 1.703 2008/05/09 18:03:14 drh Exp $
+** @(#) $Id: sqliteInt.h,v 1.704 2008/05/13 13:27:34 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
@@ -2170,14 +2170,16 @@ CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);
int sqlite3FaultFailures(int);
int sqlite3FaultBenignFailures(int);
int sqlite3FaultPending(int);
- void sqlite3FaultBenign(int,int);
+ void sqlite3FaultBeginBenign(int);
+ void sqlite3FaultEndBenign(int);
int sqlite3FaultStep(int);
#else
# define sqlite3FaultConfig(A,B,C)
# define sqlite3FaultFailures(A) 0
# define sqlite3FaultBenignFailures(A) 0
# define sqlite3FaultPending(A) (-1)
-# define sqlite3FaultBenign(A,B)
+# define sqlite3FaultBeginBenign(A)
+# define sqlite3FaultEndBenign(A)
# define sqlite3FaultStep(A) 0
#endif
diff --git a/src/test8.c b/src/test8.c
index 97762d223..539b26a77 100644
--- a/src/test8.c
+++ b/src/test8.c
@@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
-** $Id: test8.c,v 1.63 2008/05/05 13:23:04 drh Exp $
+** $Id: test8.c,v 1.64 2008/05/13 13:27:34 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@@ -1065,9 +1065,9 @@ static int echoCommit(sqlite3_vtab *tab){
** a transaction */
assert( pVtab->inTransaction );
- sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 1);
+ sqlite3FaultBeginBenign(SQLITE_FAULTINJECTOR_MALLOC);
rc = echoTransactionCall(tab, "xCommit");
- sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 0);
+ sqlite3FaultEndBenign(SQLITE_FAULTINJECTOR_MALLOC);
pVtab->inTransaction = 0;
return rc;
}
diff --git a/src/vdbe.c b/src/vdbe.c
index e22c0bddf..8215a703f 100644
--- a/src/vdbe.c
+++ b/src/vdbe.c
@@ -43,7 +43,7 @@
** in this file for details. If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
-** $Id: vdbe.c,v 1.739 2008/05/09 18:03:14 drh Exp $
+** $Id: vdbe.c,v 1.740 2008/05/13 13:27:34 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -559,7 +559,7 @@ int sqlite3VdbeExec(
CHECK_FOR_INTERRUPT;
sqlite3VdbeIOTraceSql(p);
#ifdef SQLITE_DEBUG
- sqlite3FaultBenign(-1, 1);
+ sqlite3FaultBeginBenign(-1);
if( p->pc==0 && ((p->db->flags & SQLITE_VdbeListing)!=0
|| sqlite3OsAccess(db->pVfs, "vdbe_explain", SQLITE_ACCESS_EXISTS)==1 )
){
@@ -573,7 +573,7 @@ int sqlite3VdbeExec(
if( sqlite3OsAccess(db->pVfs, "vdbe_trace", SQLITE_ACCESS_EXISTS)==1 ){
p->trace = stdout;
}
- sqlite3FaultBenign(-1, 0);
+ sqlite3FaultEndBenign(-1);
#endif
for(pc=p->pc; rc==SQLITE_OK; pc++){
assert( pc>=0 && pc<p->nOp );
@@ -595,11 +595,11 @@ int sqlite3VdbeExec(
sqlite3VdbePrintOp(p->trace, pc, pOp);
}
if( p->trace==0 && pc==0 ){
- sqlite3FaultBenign(-1, 1);
+ sqlite3FaultBeginBenign(-1);
if( sqlite3OsAccess(db->pVfs, "vdbe_sqltrace", SQLITE_ACCESS_EXISTS)==1 ){
sqlite3VdbePrintSql(p);
}
- sqlite3FaultBenign(-1, 0);
+ sqlite3FaultEndBenign(-1);
}
#endif
diff --git a/src/vdbeaux.c b/src/vdbeaux.c
index 856c4ec55..74f6c31a4 100644
--- a/src/vdbeaux.c
+++ b/src/vdbeaux.c
@@ -14,7 +14,7 @@
** to version 2.8.7, all this code was combined into the vdbe.c source file.
** But that file was getting too big so this subroutines were split out.
**
-** $Id: vdbeaux.c,v 1.382 2008/05/08 15:18:10 drh Exp $
+** $Id: vdbeaux.c,v 1.383 2008/05/13 13:27:34 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -1392,14 +1392,14 @@ static int vdbeCommit(sqlite3 *db){
** may be lying around. Returning an error code won't help matters.
*/
disable_simulated_io_errors();
- sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 1);
+ sqlite3FaultBeginBenign(SQLITE_FAULTINJECTOR_MALLOC);
for(i=0; i<db->nDb; i++){
Btree *pBt = db->aDb[i].pBt;
if( pBt ){
sqlite3BtreeCommitPhaseTwo(pBt);
}
}
- sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 0);
+ sqlite3FaultEndBenign(SQLITE_FAULTINJECTOR_MALLOC);
enable_simulated_io_errors();
sqlite3VtabCommit(db);