Index: third_party/sqlite/src/src/threads.c |
diff --git a/third_party/sqlite/src/src/threads.c b/third_party/sqlite/src/src/threads.c |
index 18d7320a123e5b74b17d0818c8310764df15d410..251b9b7631f534b68444e3c6413b6da02c953a52 100644 |
--- a/third_party/sqlite/src/src/threads.c |
+++ b/third_party/sqlite/src/src/threads.c |
@@ -26,6 +26,9 @@ |
** single-threaded if desired. |
*/ |
#include "sqliteInt.h" |
+#if SQLITE_OS_WIN |
+# include "os_win.h" |
+#endif |
#if SQLITE_MAX_WORKER_THREADS>0 |
@@ -64,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{ |
@@ -98,7 +105,7 @@ int sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){ |
/********************************* Win32 Threads ****************************/ |
-#if SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_THREADSAFE>0 |
+#if SQLITE_OS_WIN_THREADS |
#define SQLITE_THREADS_IMPLEMENTED 1 /* Prevent the single-thread code below */ |
#include <process.h> |
@@ -148,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; |
@@ -176,7 +188,7 @@ int sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){ |
assert( ppOut!=0 ); |
if( NEVER(p==0) ) return SQLITE_NOMEM; |
if( p->xTask==0 ){ |
- assert( p->id==GetCurrentThreadId() ); |
+ /* assert( p->id==GetCurrentThreadId() ); */ |
rc = WAIT_OBJECT_0; |
assert( p->tid==0 ); |
}else{ |
@@ -191,7 +203,7 @@ int sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){ |
return (rc==WAIT_OBJECT_0) ? SQLITE_OK : SQLITE_ERROR; |
} |
-#endif /* SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT */ |
+#endif /* SQLITE_OS_WIN_THREADS */ |
/******************************** End Win32 Threads *************************/ |