Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | When the in single-threaded mode, the sqlite3_mutex_alloc() interface still returns a non-NULL value. The mutex doesn't do anything, but it tests non-NULL. This way, extensions (or VFSes) that use sqlite3_mutex_alloc() can tell the difference between an OOM error and mutexes being disabled. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
451fd175758983c335aab449fdc4cb83 |
User & Date: | drh 2010-05-05 00:05:24.000 |
Context
2010-05-05
| ||
00:22 | Get the previous mutex fix working with SQLITE_DEBUG and with the amalgamation. (check-in: df19928f7e user: drh tags: trunk) | |
00:05 | When the in single-threaded mode, the sqlite3_mutex_alloc() interface still returns a non-NULL value. The mutex doesn't do anything, but it tests non-NULL. This way, extensions (or VFSes) that use sqlite3_mutex_alloc() can tell the difference between an OOM error and mutexes being disabled. (check-in: 451fd17575 user: drh tags: trunk) | |
2010-05-04
| ||
18:50 | When sqlite3PagerPagecount() is called without any locks, always return the physical file size, not the logical file size. (check-in: 4016b42228 user: drh tags: trunk) | |
Changes
Changes to src/mutex.c.
︙ | ︙ | |||
27 28 29 30 31 32 33 | #ifndef SQLITE_MUTEX_OMIT /* ** Initialize the mutex system. */ int sqlite3MutexInit(void){ int rc = SQLITE_OK; | < | | | | | | | | > > > > > | | | | | | < | 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 | #ifndef SQLITE_MUTEX_OMIT /* ** Initialize the mutex system. */ int sqlite3MutexInit(void){ int rc = SQLITE_OK; if( !sqlite3GlobalConfig.mutex.xMutexAlloc ){ /* 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 *pFrom; sqlite3_mutex_methods *pTo = &sqlite3GlobalConfig.mutex; if( sqlite3GlobalConfig.bCoreMutex ){ pFrom = sqlite3DefaultMutex(); }else{ pFrom = sqlite3NoopMutex(); } memcpy(pTo, pFrom, offsetof(sqlite3_mutex_methods, xMutexAlloc)); memcpy(&pTo->xMutexFree, &pFrom->xMutexFree, sizeof(*pTo) - offsetof(sqlite3_mutex_methods, xMutexFree)); pTo->xMutexAlloc = pFrom->xMutexAlloc; } rc = sqlite3GlobalConfig.mutex.xMutexInit(); #ifdef SQLITE_DEBUG GLOBAL(int, mutexIsInit) = 1; #endif return rc; } |
︙ | ︙ | |||
73 74 75 76 77 78 79 | return rc; } /* ** Retrieve a pointer to a static mutex or allocate a new dynamic one. */ sqlite3_mutex *sqlite3_mutex_alloc(int id){ | < | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | return rc; } /* ** Retrieve a pointer to a static mutex or allocate a new dynamic one. */ sqlite3_mutex *sqlite3_mutex_alloc(int id){ #ifndef SQLITE_OMIT_AUTOINIT if( sqlite3_initialize() ) return 0; #endif return sqlite3GlobalConfig.mutex.xMutexAlloc(id); } sqlite3_mutex *sqlite3MutexAlloc(int id){ |
︙ | ︙ |
Changes to src/mutex_noop.c.
︙ | ︙ | |||
24 25 26 27 28 29 30 | ** If compiled with SQLITE_DEBUG, then additional logic is inserted ** that does error checking on mutexes to make sure they are being ** called correctly. */ #include "sqliteInt.h" | | | | | | 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 62 63 64 65 66 67 68 69 70 71 72 | ** If compiled with SQLITE_DEBUG, then additional logic is inserted ** that does error checking on mutexes to make sure they are being ** called correctly. */ #include "sqliteInt.h" #ifndef SQLITE_DEBUG /* ** Stub routines for all mutex methods. ** ** This routines provide no mutual exclusion or error checking. */ static int noopMutexHeld(sqlite3_mutex *p){ return 1; } static int noopMutexNotheld(sqlite3_mutex *p){ return 1; } static int noopMutexInit(void){ return SQLITE_OK; } static int noopMutexEnd(void){ return SQLITE_OK; } static sqlite3_mutex *noopMutexAlloc(int id){ return (sqlite3_mutex*)8; } static void noopMutexFree(sqlite3_mutex *p){ return; } static void noopMutexEnter(sqlite3_mutex *p){ return; } static int noopMutexTry(sqlite3_mutex *p){ return SQLITE_OK; } static void noopMutexLeave(sqlite3_mutex *p){ return; } sqlite3_mutex_methods *sqlite3NoopMutex(void){ static sqlite3_mutex_methods sMutex = { noopMutexInit, noopMutexEnd, noopMutexAlloc, noopMutexFree, noopMutexEnter, noopMutexTry, noopMutexLeave, noopMutexHeld, noopMutexNotheld }; return &sMutex; } #endif /* !SQLITE_DEBUG */ #ifdef SQLITE_DEBUG /* ** In this implementation, error checking is provided for testing ** and debugging purposes. The mutexes still do not provide any ** mutual exclusion. */ /* |
︙ | ︙ | |||
161 162 163 164 165 166 167 | */ static void debugMutexLeave(sqlite3_mutex *p){ assert( debugMutexHeld(p) ); p->cnt--; assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(p) ); } | | > > > > > > | > > > > | 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | */ static void debugMutexLeave(sqlite3_mutex *p){ assert( debugMutexHeld(p) ); p->cnt--; assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(p) ); } sqlite3_mutex_methods *sqlite3NoopMutex(void){ static sqlite3_mutex_methods sMutex = { debugMutexInit, debugMutexEnd, debugMutexAlloc, debugMutexFree, debugMutexEnter, debugMutexTry, debugMutexLeave, debugMutexHeld, debugMutexNotheld }; return &sMutex; } #endif /* SQLITE_DEBUG */ /* ** If compiled with SQLITE_MUTEX_NOOP, then the no-op mutex implementation ** is used regardless of the run-time threadsafety setting. */ #ifdef SQLITE_MUTEX_NOOP sqlite3_mutex_methods *sqlite3DefaultMutex(void){ return sqliteNoopMutex(); } #endif /* SQLITE_MUTEX_NOOP */ |
Changes to src/sqliteInt.h.
︙ | ︙ | |||
2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 | #ifdef SQLITE_ENABLE_MEMSYS5 const sqlite3_mem_methods *sqlite3MemGetMemsys5(void); #endif #ifndef SQLITE_MUTEX_OMIT sqlite3_mutex_methods *sqlite3DefaultMutex(void); sqlite3_mutex *sqlite3MutexAlloc(int); int sqlite3MutexInit(void); int sqlite3MutexEnd(void); #endif int sqlite3StatusValue(int); void sqlite3StatusAdd(int, int); | > | 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 | #ifdef SQLITE_ENABLE_MEMSYS5 const sqlite3_mem_methods *sqlite3MemGetMemsys5(void); #endif #ifndef SQLITE_MUTEX_OMIT sqlite3_mutex_methods *sqlite3DefaultMutex(void); sqlite3_mutex_methods *sqlite3NoopMutex(void); sqlite3_mutex *sqlite3MutexAlloc(int); int sqlite3MutexInit(void); int sqlite3MutexEnd(void); #endif int sqlite3StatusValue(int); void sqlite3StatusAdd(int, int); |
︙ | ︙ |