diff options
author | drh <drh@noemail.net> | 2018-02-05 16:39:12 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2018-02-05 16:39:12 +0000 |
commit | 561158937bab6dcd057026dc554d28a35c7e0bd6 (patch) | |
tree | f0aa6ce7f0a5f687111d0d7494534f1f054d4bcc /src/os_unix.c | |
parent | d1317095b58e87e9543fc35b418b59c70003deb0 (diff) | |
download | sqlite-561158937bab6dcd057026dc554d28a35c7e0bd6.tar.gz sqlite-561158937bab6dcd057026dc554d28a35c7e0bd6.zip |
Allocation the mutex used by the unix VFS only once at initialization, instead
of every time it is needed.
FossilOrigin-Name: 5764dc160783f5c4017204b3e26a89d31240c868484ced8214c9ad872bd77bd4
Diffstat (limited to 'src/os_unix.c')
-rw-r--r-- | src/os_unix.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 94b1efd87..b24c6861d 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -696,15 +696,16 @@ static int robust_open(const char *z, int f, mode_t m){ ** assert( unixMutexHeld() ); ** unixEnterLeave() */ +static sqlite3_mutex *unixBigLock = 0; static void unixEnterMutex(void){ - sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1)); + sqlite3_mutex_enter(unixBigLock); } static void unixLeaveMutex(void){ - sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1)); + sqlite3_mutex_leave(unixBigLock); } #ifdef SQLITE_DEBUG static int unixMutexHeld(void) { - return sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1)); + return sqlite3_mutex_held(unixBigLock); } #endif @@ -5846,7 +5847,6 @@ static int unixOpen( randomnessPid = osGetpid(0); sqlite3_randomness(0,0); } - memset(p, 0, sizeof(unixFile)); if( eType==SQLITE_OPEN_MAIN_DB ){ @@ -7721,6 +7721,7 @@ int sqlite3_os_init(void){ for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){ sqlite3_vfs_register(&aVfs[i], i==0); } + unixBigLock = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1); return SQLITE_OK; } @@ -7732,6 +7733,7 @@ int sqlite3_os_init(void){ ** This routine is a no-op for unix. */ int sqlite3_os_end(void){ + unixBigLock = 0; return SQLITE_OK; } |