/ Check-in [c9400ff1]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Experimental changes to avoid recusrively calling xMutexInit.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | mutexInitCmpSwap
Files: files | file ages | folders
SHA1: c9400ff167d9520119081c9b92436794dcd53d22
User & Date: mistachkin 2015-09-13 18:45:50
Context
2015-09-23
15:54
Merge updates from trunk. Closed-Leaf check-in: 6b85f8cd user: mistachkin tags: mutexInitCmpSwap
2015-09-13
18:45
Experimental changes to avoid recusrively calling xMutexInit. check-in: c9400ff1 user: mistachkin tags: mutexInitCmpSwap
18:43
Merge updates from trunk. check-in: b42c2e20 user: mistachkin tags: mutexInitCmpSwap
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/mutex.c.

    71     71     pTo->xMutexAlloc = pFrom->xMutexAlloc;
    72     72   }
    73     73   
    74     74   /*
    75     75   ** Initialize the mutex system.
    76     76   */
    77     77   int sqlite3MutexInit(void){ 
           78  +  static int initPending = 0;
    78     79     int rc;
    79     80     if( sqlite3CompareAndSwap((void * volatile *)&sqlite3GlobalConfig.pMutex,
    80     81                      0, &sqlite3GlobalConfig.mutex)==0 || mutexIsInvalid() ){
    81     82       /* If the mutex implementation pointer has not been set, then the user
    82     83       ** did not install a mutex implementation via sqlite3_config() prior to
    83     84       ** sqlite3_initialize() being called.  This block copies the pointers
    84     85       ** for the default implementation into the sqlite3GlobalConfig structure.
................................................................................
    89     90         pFrom = sqlite3DefaultMutex();
    90     91       }else{
    91     92         pFrom = sqlite3NoopMutex();
    92     93       }
    93     94       mutexCopy(&sqlite3GlobalConfig.mutex, pFrom);
    94     95       sqlite3MemoryBarrier();
    95     96     }
    96         -  assert( sqlite3GlobalConfig.mutex.xMutexInit );
    97         -  rc = sqlite3GlobalConfig.mutex.xMutexInit();
           97  +  if( !initPending ){
           98  +    assert( sqlite3GlobalConfig.mutex.xMutexInit );
           99  +    initPending = 1;
          100  +    rc = sqlite3GlobalConfig.mutex.xMutexInit();
          101  +    initPending = 0;
          102  +  }
    98    103   
    99    104   #ifdef SQLITE_DEBUG
   100    105     GLOBAL(int, mutexIsInit) = 1;
   101    106   #endif
   102    107   
   103    108     return rc;
   104    109   }