Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Ensure that "static" mutexes are deleted on shutdown so that they are not leaked across restarts. (CVS 6700) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
4e75897ee177bd24145f9dbfccd41a03 |
User & Date: | shane 2009-06-01 17:06:08.000 |
Context
2009-06-01
| ||
17:10 | Added assert to verify winMutex system is inited before "static" mutexes are used. (CVS 6701) (check-in: b126013b5a user: shane tags: trunk) | |
17:06 | Ensure that "static" mutexes are deleted on shutdown so that they are not leaked across restarts. (CVS 6700) (check-in: 4e75897ee1 user: shane tags: trunk) | |
16:53 | Fix compiler warnings with MSVC build. (CVS 6699) (check-in: 0791588520 user: shane tags: trunk) | |
Changes
Changes to src/mutex_w32.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* ** 2007 August 14 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains the C functions that implement mutexes for win32 ** | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* ** 2007 August 14 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains the C functions that implement mutexes for win32 ** ** $Id: mutex_w32.c,v 1.16 2009/06/01 17:06:08 shane Exp $ */ #include "sqliteInt.h" /* ** The code in this file is only used if we are compiling multithreaded ** on a win32 system. */ |
︙ | ︙ | |||
78 79 80 81 82 83 84 | } #endif /* ** Initialize and deinitialize the mutex subsystem. */ | > > > > > > > > > | > > > > > > > > > > > > > > > | > > > > > > > > > > > > > | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | } #endif /* ** Initialize and deinitialize the mutex subsystem. */ static sqlite3_mutex winMutex_staticMutexes[6]; static int winMutex_isInit = 0; /* As winMutexInit() and winMutexEnd() are called as part ** of the sqlite3_initialize and sqlite3_shutdown() ** processing, the "interlocked" magic is probably not ** strictly necessary. */ static long winMutex_lock = 0; static int winMutexInit(void){ /* The first to increment to 1 does actual initialization */ if( InterlockedIncrement(&winMutex_lock)==1 ){ int i; for(i=0; i<sizeof(winMutex_staticMutexes)/sizeof(winMutex_staticMutexes[0]); i++){ InitializeCriticalSection(&winMutex_staticMutexes[i].mutex); } winMutex_isInit = 1; }else{ while( !winMutex_isInit ){ Sleep(1); } } return SQLITE_OK; } static int winMutexEnd(void){ /* The first to decrement to 0 does actual shutdown ** (which should be the last to shutdown.) */ if( InterlockedDecrement(&winMutex_lock)==0 ){ if( winMutex_isInit==1 ){ int i; for(i=0; i<sizeof(winMutex_staticMutexes)/sizeof(winMutex_staticMutexes[0]); i++){ DeleteCriticalSection(&winMutex_staticMutexes[i].mutex); } winMutex_isInit = 0; } } return SQLITE_OK; } /* ** The sqlite3_mutex_alloc() routine allocates a new ** mutex and returns a pointer to it. If it returns NULL ** that means that a mutex could not be allocated. SQLite ** will unwind its stack and return an error. The argument ** to sqlite3_mutex_alloc() is one of these integer constants: |
︙ | ︙ | |||
127 128 129 130 131 132 133 | static sqlite3_mutex *winMutexAlloc(int iType){ sqlite3_mutex *p; switch( iType ){ case SQLITE_MUTEX_FAST: case SQLITE_MUTEX_RECURSIVE: { p = sqlite3MallocZero( sizeof(*p) ); | | < < < < < < < < < < < < < < | | | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | static sqlite3_mutex *winMutexAlloc(int iType){ sqlite3_mutex *p; switch( iType ){ case SQLITE_MUTEX_FAST: case SQLITE_MUTEX_RECURSIVE: { p = sqlite3MallocZero( sizeof(*p) ); if( p ){ p->id = iType; InitializeCriticalSection(&p->mutex); } break; } default: { assert( iType-2 >= 0 ); assert( iType-2 < sizeof(winMutex_staticMutexes)/sizeof(winMutex_staticMutexes[0]) ); p = &winMutex_staticMutexes[iType-2]; p->id = iType; break; } } return p; } |
︙ | ︙ |