/ Check-in [2d867c05]
Login

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

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2d867c054d6d3e1e841ba9ca524e986bc6993ac3
User & Date: drh 2015-09-25 23:40:01
Context
2015-09-26
01:28
Remove an assert in the windows worker-thread logic that can fail in a race condition. check-in: d7bfb960 user: drh tags: trunk
2015-09-25
23:40
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. check-in: 2d867c05 user: drh tags: trunk
20:49
Fix PRAGMA integrity_check so that it works with a UNIQUE index over expressions. check-in: 113181ce user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/threads.c.

    63     63   
    64     64     *ppThread = 0;
    65     65     p = sqlite3Malloc(sizeof(*p));
    66     66     if( p==0 ) return SQLITE_NOMEM;
    67     67     memset(p, 0, sizeof(*p));
    68     68     p->xTask = xTask;
    69     69     p->pIn = pIn;
           70  +  /* If the SQLITE_TESTCTRL_FAULT_INSTALL callback is registered to a 
           71  +  ** function that returns SQLITE_ERROR when passed the argument 200, that
           72  +  ** forces worker threads to run sequentially and deterministically 
           73  +  ** for testing purposes. */
    70     74     if( sqlite3FaultSim(200) ){
    71     75       rc = 1;
    72     76     }else{    
    73     77       rc = pthread_create(&p->tid, 0, xTask, pIn);
    74     78     }
    75     79     if( rc ){
    76     80       p->done = 1;
................................................................................
   147    151     SQLiteThread *p;
   148    152   
   149    153     assert( ppThread!=0 );
   150    154     assert( xTask!=0 );
   151    155     *ppThread = 0;
   152    156     p = sqlite3Malloc(sizeof(*p));
   153    157     if( p==0 ) return SQLITE_NOMEM;
   154         -  if( sqlite3GlobalConfig.bCoreMutex==0 ){
          158  +  /* If the SQLITE_TESTCTRL_FAULT_INSTALL callback is registered to a 
          159  +  ** function that returns SQLITE_ERROR when passed the argument 200, that
          160  +  ** forces worker threads to run sequentially and deterministically 
          161  +  ** (via the sqlite3FaultSim() term of the conditional) for testing
          162  +  ** purposes. */
          163  +  if( sqlite3GlobalConfig.bCoreMutex==0 || sqlite3FaultSim(200) ){
   155    164       memset(p, 0, sizeof(*p));
   156    165     }else{
   157    166       p->xTask = xTask;
   158    167       p->pIn = pIn;
   159    168       p->tid = (void*)_beginthreadex(0, 0, sqlite3ThreadProc, p, 0, &p->id);
   160    169       if( p->tid==0 ){
   161    170         memset(p, 0, sizeof(*p));