/ Check-in [1a97bc81]
Login

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

Overview
Comment:Specifying an invalid mutex implementation (via SQLITE_CONFIG_MUTEX) should cause the default one to be used instead.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | mutexInitCmpSwap
Files: files | file ages | folders
SHA1: 1a97bc81ccfc88f2dd527dff16e9e395718675bc
User & Date: mistachkin 2015-09-12 04:19:51
Context
2015-09-12
04:22
Fix comments. check-in: de3fa51e 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: 1a97bc81 user: mistachkin tags: mutexInitCmpSwap
03:40
Clarify the new mutex implementation reset logic in sqlite3_shutdown(). check-in: f9a03483 user: mistachkin tags: mutexInitCmpSwap
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/mutex.c.

22
23
24
25
26
27
28


























29
30
31
32
33
34
35
..
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
** allocate a mutex while the system is uninitialized.
*/
static SQLITE_WSD int mutexIsInit = 0;
#endif /* SQLITE_DEBUG && !defined(SQLITE_MUTEX_OMIT) */


#ifndef SQLITE_MUTEX_OMIT


























/*
** Copies a mutex implementation.  Both arguments must point to valid
** memory.
*/
static void mutexCopy(
  sqlite3_mutex_methods *pTo,
  sqlite3_mutex_methods const *pFrom
................................................................................

/*
** Initialize the mutex system.
*/
int sqlite3MutexInit(void){ 
  int rc;
  if( sqlite3CompareAndSwap((void * volatile *)&sqlite3GlobalConfig.pMutex,
                            0, &sqlite3GlobalConfig.mutex)==0 ){
    /* 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;








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
..
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
** allocate a mutex while the system is uninitialized.
*/
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 */
  0, /* xMutexFree */
  0, /* xMutexEnter */
  0, /* xMutexTry */
  0, /* xMutexLeave */
  0, /* xMutexHeld */
  0  /* xMutexNotheld */
};

/*
** Returns non-zero if the currently configured mutex implemention is
** invalid (i.e. all of its function pointers are null).
*/
static int mutexIsInvalid(void){
  return memcmp(&sqlite3GlobalConfig.mutex, &mutexNullMethods,
                sizeof(sqlite3_mutex_methods))==0;
}

/*
** Copies a mutex implementation.  Both arguments must point to valid
** memory.
*/
static void mutexCopy(
  sqlite3_mutex_methods *pTo,
  sqlite3_mutex_methods const *pFrom
................................................................................

/*
** 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;