/ Check-in [386e0888]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Improvements to the testability of the threads.c module.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | threads
Files: files | file ages | folders
SHA1: 386e088868b44b02646e452147838d2e97b093ee
User & Date: drh 2014-05-20 19:11:50
Context
2014-05-26
20:15
Merge recent trunk changes into the threads branch. check-in: 82152027 user: drh tags: threads
2014-05-20
19:11
Improvements to the testability of the threads.c module. check-in: 386e0888 user: drh tags: threads
11:03
In vdbesort.c, change the names of PmaReader variables "pIter" to "pReadr". Other related comment changes. The generated object code should be the same. check-in: 99efb235 user: drh tags: threads
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/threads.c.

    50     50     void *(*xTask)(void*),    /* Routine to run in a separate thread */
    51     51     void *pIn                 /* Argument passed into xTask() */
    52     52   ){
    53     53     SQLiteThread *p;
    54     54   
    55     55     assert( ppThread!=0 );
    56     56     assert( xTask!=0 );
           57  +  /* This routine is never used in single-threaded mode */
           58  +  assert( sqlite3GlobalConfig.bCoreMutex!=0 );
           59  +
    57     60     *ppThread = 0;
    58     61     p = sqlite3Malloc(sizeof(*p));
    59     62     if( p==0 ) return SQLITE_NOMEM;
    60     63     memset(p, 0, sizeof(*p));
    61     64     p->xTask = xTask;
    62     65     p->pIn = pIn;
    63         -  if( sqlite3GlobalConfig.bCoreMutex==0
    64         -    || pthread_create(&p->tid, 0, xTask, pIn)!=0 
    65         -  ){
           66  +  if( sqlite3FaultSim(200) ? 1 : pthread_create(&p->tid, 0, xTask, pIn) ){
    66     67       p->done = 1;
    67     68       p->pOut = xTask(pIn);
    68     69     }
    69     70     *ppThread = p;
    70     71     return SQLITE_OK;
    71     72   }
    72     73   
................................................................................
    76     77   
    77     78     assert( ppOut!=0 );
    78     79     if( p==0 ) return SQLITE_NOMEM;
    79     80     if( p->done ){
    80     81       *ppOut = p->pOut;
    81     82       rc = SQLITE_OK;
    82     83     }else{
    83         -    rc = pthread_join(p->tid, ppOut);
           84  +    rc = pthread_join(p->tid, ppOut) ? SQLITE_ERROR : SQLITE_OK;
    84     85     }
    85     86     sqlite3_free(p);
    86         -  return rc ? SQLITE_ERROR : SQLITE_OK;
           87  +  return rc;
    87     88   }
    88     89   
    89     90   #endif /* SQLITE_OS_UNIX && defined(SQLITE_MUTEX_PTHREADS) */
    90     91   /******************************** End Unix Pthreads *************************/
    91     92   
    92     93   
    93     94   /********************************* Win32 Threads ****************************/