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

@@ -1,5 +1,5 @@
C Fix\sPRAGMA\sintegrity_check\sso\sthat\sit\sworks\swith\sa\sUNIQUE\sindex\sover\nexpressions. C Fix\sthreads.c\sso\sthat\ssetting\ssqlite3FaultSim(200)\susing\sthe\nSQLITE_TESTCTRL_FAULT_INSTALL\scallback\scauses\sboth\sunix\sand\swindows\sworker\nthreads\sto\sbe\ssequential\sand\sdeterministic,\sso\sthat\sthey\scan\sbe\stested\nreliably.
D 2015-09-25T20:49:16.032 D 2015-09-25T23:40:01.663
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in e1afa6fb2de2bddd50e0ddae8166c2ee9d69b301 F Makefile.in e1afa6fb2de2bddd50e0ddae8166c2ee9d69b301
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -395,7 +395,7 @@ F src/test_thread.c af391ec03d23486dffbcc250b7e58e073f172af9
F src/test_vfs.c 3b65d42e18b262805716bd96178c81da8f2d9283 F src/test_vfs.c 3b65d42e18b262805716bd96178c81da8f2d9283
F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698
F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
F src/threads.c 6bbcc9fe50c917864d48287b4792d46d6e873481 F src/threads.c 87639bc293d470f50d48c370028511ad3e1ccfd5
F src/tokenize.c 83c6ed569423a3af83a83973b444cf7123be33a6 F src/tokenize.c 83c6ed569423a3af83a83973b444cf7123be33a6
F src/treeview.c 154f0acc622fa3514de8777dcedf4c8a8802b4ce F src/treeview.c 154f0acc622fa3514de8777dcedf4c8a8802b4ce
F src/trigger.c 322f23aad694e8f31d384dcfa386d52a48d3c52f F src/trigger.c 322f23aad694e8f31d384dcfa386d52a48d3c52f
@@ -1388,7 +1388,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 6e4ac0be2de1a16fcbb2a314504122ad95aa257e P 113181cec4db418b07640d6b1967923992efd71a
R ddf8c16716e71dc2258fab1042b22895 R c9cd2c770b7c10173d40a9ea442ad6dd
U drh U drh
Z 58a6b6e5eae00c6fe24fb1e13719f1e4 Z 0fbda38735b1950a4a02ae04b92eb3a5

View File

@@ -1 +1 @@
113181cec4db418b07640d6b1967923992efd71a 2d867c054d6d3e1e841ba9ca524e986bc6993ac3

View File

@@ -67,6 +67,10 @@ int sqlite3ThreadCreate(
memset(p, 0, sizeof(*p)); memset(p, 0, sizeof(*p));
p->xTask = xTask; p->xTask = xTask;
p->pIn = pIn; 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) ){ if( sqlite3FaultSim(200) ){
rc = 1; rc = 1;
}else{ }else{
@@ -151,7 +155,12 @@ int sqlite3ThreadCreate(
*ppThread = 0; *ppThread = 0;
p = sqlite3Malloc(sizeof(*p)); p = sqlite3Malloc(sizeof(*p));
if( p==0 ) return SQLITE_NOMEM; 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)); memset(p, 0, sizeof(*p));
}else{ }else{
p->xTask = xTask; p->xTask = xTask;