diff options
author | drh <drh@noemail.net> | 2014-05-20 19:11:50 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2014-05-20 19:11:50 +0000 |
commit | cb6effafecd4bbd73a55002e4df081c2e687451b (patch) | |
tree | 6e998e2e4e551e9da1352ac8173156c1d4bf903a /src/threads.c | |
parent | de823bedefdbadcffb818c5bafdd90f344fc94bb (diff) | |
download | sqlite-cb6effafecd4bbd73a55002e4df081c2e687451b.tar.gz sqlite-cb6effafecd4bbd73a55002e4df081c2e687451b.zip |
Improvements to the testability of the threads.c module.
FossilOrigin-Name: 386e088868b44b02646e452147838d2e97b093ee
Diffstat (limited to 'src/threads.c')
-rw-r--r-- | src/threads.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/threads.c b/src/threads.c index 6b59ce90d..1cfe2cc6c 100644 --- a/src/threads.c +++ b/src/threads.c @@ -54,15 +54,16 @@ int sqlite3ThreadCreate( assert( ppThread!=0 ); assert( xTask!=0 ); + /* This routine is never used in single-threaded mode */ + assert( sqlite3GlobalConfig.bCoreMutex!=0 ); + *ppThread = 0; p = sqlite3Malloc(sizeof(*p)); if( p==0 ) return SQLITE_NOMEM; memset(p, 0, sizeof(*p)); p->xTask = xTask; p->pIn = pIn; - if( sqlite3GlobalConfig.bCoreMutex==0 - || pthread_create(&p->tid, 0, xTask, pIn)!=0 - ){ + if( sqlite3FaultSim(200) ? 1 : pthread_create(&p->tid, 0, xTask, pIn) ){ p->done = 1; p->pOut = xTask(pIn); } @@ -80,10 +81,10 @@ int sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){ *ppOut = p->pOut; rc = SQLITE_OK; }else{ - rc = pthread_join(p->tid, ppOut); + rc = pthread_join(p->tid, ppOut) ? SQLITE_ERROR : SQLITE_OK; } sqlite3_free(p); - return rc ? SQLITE_ERROR : SQLITE_OK; + return rc; } #endif /* SQLITE_OS_UNIX && defined(SQLITE_MUTEX_PTHREADS) */ |