1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

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
This commit is contained in:
drh
2015-09-25 23:40:01 +00:00
parent 68391acd5f
commit 2ea31b1286
3 changed files with 17 additions and 8 deletions

View File

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