SQLite

Check-in [de3fa51e93]
Login

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

Overview
Comment:Fix comments.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | mutexInitCmpSwap
Files: files | file ages | folders
SHA1: de3fa51e931d34f341fc3432bfdf97390bb68d4e
User & Date: mistachkin 2015-09-12 04:22:01.762
Context
2015-09-12
16:59
Merge updates from trunk. (check-in: 4859778900 user: mistachkin tags: mutexInitCmpSwap)
04:22
Fix comments. (check-in: de3fa51e93 user: mistachkin tags: mutexInitCmpSwap)
04:19
Specifying an invalid mutex implementation (via SQLITE_CONFIG_MUTEX) should cause the default one to be used instead. (check-in: 1a97bc81cc user: mistachkin tags: mutexInitCmpSwap)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/mutex.c.
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
*/
static SQLITE_WSD int mutexIsInit = 0;
#endif /* SQLITE_DEBUG && !defined(SQLITE_MUTEX_OMIT) */


#ifndef SQLITE_MUTEX_OMIT
/*
** This structure is for use by sqlite3MutexInit() only.  It represents an
** invalid mutex implementation (i.e. one where all the function pointers
** are null).
*/
static const sqlite3_mutex_methods mutexNullMethods = {
  0, /* xMutexInit */
  0, /* xMutexEnd */
  0, /* xMutexAlloc */







|







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
*/
static SQLITE_WSD int mutexIsInit = 0;
#endif /* SQLITE_DEBUG && !defined(SQLITE_MUTEX_OMIT) */


#ifndef SQLITE_MUTEX_OMIT
/*
** This structure is for use by mutexIsInvalid() only.  It represents an
** invalid mutex implementation (i.e. one where all the function pointers
** are null).
*/
static const sqlite3_mutex_methods mutexNullMethods = {
  0, /* xMutexInit */
  0, /* xMutexEnd */
  0, /* xMutexAlloc */
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
** Initialize the mutex system.
*/
int sqlite3MutexInit(void){ 
  int rc;
  if( sqlite3CompareAndSwap((void * volatile *)&sqlite3GlobalConfig.pMutex,
                   0, &sqlite3GlobalConfig.mutex)==0 || mutexIsInvalid() ){
    /* If the xMutexAlloc method has not been set, then the user did not
    ** install a mutex implementation via sqlite3_config() prior to 
    ** sqlite3_initialize() being called. This block copies pointers to
    ** the default implementation into the sqlite3GlobalConfig structure.
    */
    sqlite3_mutex_methods const *pFrom;

    if( sqlite3GlobalConfig.bCoreMutex ){
      pFrom = sqlite3DefaultMutex();
    }else{
      pFrom = sqlite3NoopMutex();







|
|
|
|







74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
** Initialize the mutex system.
*/
int sqlite3MutexInit(void){ 
  int rc;
  if( sqlite3CompareAndSwap((void * volatile *)&sqlite3GlobalConfig.pMutex,
                   0, &sqlite3GlobalConfig.mutex)==0 || mutexIsInvalid() ){
    /* If the mutex implementation pointer has not been set, then the user
    ** did not install a mutex implementation via sqlite3_config() prior to
    ** sqlite3_initialize() being called.  This block copies the pointers
    ** for the default implementation into the sqlite3GlobalConfig structure.
    */
    sqlite3_mutex_methods const *pFrom;

    if( sqlite3GlobalConfig.bCoreMutex ){
      pFrom = sqlite3DefaultMutex();
    }else{
      pFrom = sqlite3NoopMutex();