aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2015-09-25 23:40:01 +0000
committerdrh <drh@noemail.net>2015-09-25 23:40:01 +0000
commit2ea31b1286adb309baad799e5e82a2d28071d785 (patch)
tree73333659785748e9d0a65e025347ba29ee10a50a /src
parent68391acd5f11ec64e74eca419ec8088f26c03c5c (diff)
downloadsqlite-2ea31b1286adb309baad799e5e82a2d28071d785.tar.gz
sqlite-2ea31b1286adb309baad799e5e82a2d28071d785.zip
Fix threads.c so that setting sqlite3FaultSim(200) using the
SQLITE_TESTCTRL_FAULT_INSTALL callback causes both unix and windows worker threads to be sequential and deterministic, so that they can be tested reliably. FossilOrigin-Name: 2d867c054d6d3e1e841ba9ca524e986bc6993ac3
Diffstat (limited to 'src')
-rw-r--r--src/threads.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/threads.c b/src/threads.c
index 4ce612227..8ed2b4261 100644
--- a/src/threads.c
+++ b/src/threads.c
@@ -67,6 +67,10 @@ int sqlite3ThreadCreate(
memset(p, 0, sizeof(*p));
p->xTask = xTask;
p->pIn = pIn;
+ /* If the SQLITE_TESTCTRL_FAULT_INSTALL callback is registered to a
+ ** function that returns SQLITE_ERROR when passed the argument 200, that
+ ** forces worker threads to run sequentially and deterministically
+ ** for testing purposes. */
if( sqlite3FaultSim(200) ){
rc = 1;
}else{
@@ -151,7 +155,12 @@ int sqlite3ThreadCreate(
*ppThread = 0;
p = sqlite3Malloc(sizeof(*p));
if( p==0 ) return SQLITE_NOMEM;
- if( sqlite3GlobalConfig.bCoreMutex==0 ){
+ /* If the SQLITE_TESTCTRL_FAULT_INSTALL callback is registered to a
+ ** function that returns SQLITE_ERROR when passed the argument 200, that
+ ** forces worker threads to run sequentially and deterministically
+ ** (via the sqlite3FaultSim() term of the conditional) for testing
+ ** purposes. */
+ if( sqlite3GlobalConfig.bCoreMutex==0 || sqlite3FaultSim(200) ){
memset(p, 0, sizeof(*p));
}else{
p->xTask = xTask;