| Index: third_party/sqlite/sqlite-src-3100200/src/mutex_w32.c
|
| diff --git a/third_party/sqlite/sqlite-src-3080704/src/mutex_w32.c b/third_party/sqlite/sqlite-src-3100200/src/mutex_w32.c
|
| similarity index 90%
|
| copy from third_party/sqlite/sqlite-src-3080704/src/mutex_w32.c
|
| copy to third_party/sqlite/sqlite-src-3100200/src/mutex_w32.c
|
| index da7d73f7c5896931836a7315cc444001fff24f2b..9570bdc0bf452d6695c19684fb10cfe1611f70c6 100644
|
| --- a/third_party/sqlite/sqlite-src-3080704/src/mutex_w32.c
|
| +++ b/third_party/sqlite/sqlite-src-3100200/src/mutex_w32.c
|
| @@ -78,6 +78,24 @@ static int winMutexNotheld(sqlite3_mutex *p){
|
| #endif
|
|
|
| /*
|
| +** Try to provide a memory barrier operation, needed for initialization
|
| +** and also for the xShmBarrier method of the VFS in cases when SQLite is
|
| +** compiled without mutexes (SQLITE_THREADSAFE=0).
|
| +*/
|
| +void sqlite3MemoryBarrier(void){
|
| +#if defined(SQLITE_MEMORY_BARRIER)
|
| + SQLITE_MEMORY_BARRIER;
|
| +#elif defined(__GNUC__)
|
| + __sync_synchronize();
|
| +#elif !defined(SQLITE_DISABLE_INTRINSIC) && \
|
| + defined(_MSC_VER) && _MSC_VER>=1300
|
| + _ReadWriteBarrier();
|
| +#elif defined(MemoryBarrier)
|
| + MemoryBarrier();
|
| +#endif
|
| +}
|
| +
|
| +/*
|
| ** Initialize and deinitialize the mutex subsystem.
|
| */
|
| static sqlite3_mutex winMutex_staticMutexes[] = {
|
| @@ -89,6 +107,9 @@ static sqlite3_mutex winMutex_staticMutexes[] = {
|
| SQLITE3_MUTEX_INITIALIZER,
|
| SQLITE3_MUTEX_INITIALIZER,
|
| SQLITE3_MUTEX_INITIALIZER,
|
| + SQLITE3_MUTEX_INITIALIZER,
|
| + SQLITE3_MUTEX_INITIALIZER,
|
| + SQLITE3_MUTEX_INITIALIZER,
|
| SQLITE3_MUTEX_INITIALIZER
|
| };
|
|
|
| @@ -160,6 +181,9 @@ static int winMutexEnd(void){
|
| ** <li> SQLITE_MUTEX_STATIC_APP1
|
| ** <li> SQLITE_MUTEX_STATIC_APP2
|
| ** <li> SQLITE_MUTEX_STATIC_APP3
|
| +** <li> SQLITE_MUTEX_STATIC_VFS1
|
| +** <li> SQLITE_MUTEX_STATIC_VFS2
|
| +** <li> SQLITE_MUTEX_STATIC_VFS3
|
| ** </ul>
|
| **
|
| ** The first two constants cause sqlite3_mutex_alloc() to create
|
| @@ -194,8 +218,8 @@ static sqlite3_mutex *winMutexAlloc(int iType){
|
| case SQLITE_MUTEX_RECURSIVE: {
|
| p = sqlite3MallocZero( sizeof(*p) );
|
| if( p ){
|
| -#ifdef SQLITE_DEBUG
|
| p->id = iType;
|
| +#ifdef SQLITE_DEBUG
|
| #ifdef SQLITE_WIN32_MUTEX_TRACE_DYNAMIC
|
| p->trace = 1;
|
| #endif
|
| @@ -209,12 +233,15 @@ static sqlite3_mutex *winMutexAlloc(int iType){
|
| break;
|
| }
|
| default: {
|
| - assert( iType-2 >= 0 );
|
| - assert( iType-2 < ArraySize(winMutex_staticMutexes) );
|
| - assert( winMutex_isInit==1 );
|
| +#ifdef SQLITE_ENABLE_API_ARMOR
|
| + if( iType-2<0 || iType-2>=ArraySize(winMutex_staticMutexes) ){
|
| + (void)SQLITE_MISUSE_BKPT;
|
| + return 0;
|
| + }
|
| +#endif
|
| p = &winMutex_staticMutexes[iType-2];
|
| -#ifdef SQLITE_DEBUG
|
| p->id = iType;
|
| +#ifdef SQLITE_DEBUG
|
| #ifdef SQLITE_WIN32_MUTEX_TRACE_STATIC
|
| p->trace = 1;
|
| #endif
|
| @@ -233,13 +260,15 @@ static sqlite3_mutex *winMutexAlloc(int iType){
|
| */
|
| static void winMutexFree(sqlite3_mutex *p){
|
| assert( p );
|
| -#ifdef SQLITE_DEBUG
|
| assert( p->nRef==0 && p->owner==0 );
|
| - assert( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE );
|
| + if( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE ){
|
| + DeleteCriticalSection(&p->mutex);
|
| + sqlite3_free(p);
|
| + }else{
|
| +#ifdef SQLITE_ENABLE_API_ARMOR
|
| + (void)SQLITE_MISUSE_BKPT;
|
| #endif
|
| - assert( winMutex_isInit==1 );
|
| - DeleteCriticalSection(&p->mutex);
|
| - sqlite3_free(p);
|
| + }
|
| }
|
|
|
| /*
|
|
|