1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-15 11:41:13 +03:00

Performance fix for winShmClose().

FossilOrigin-Name: ed7774de04978803e979580240148eba1de9166d
This commit is contained in:
drh
2010-06-03 18:02:48 +00:00
parent db9d981a8d
commit 05cb5b244b
3 changed files with 26 additions and 16 deletions

View File

@@ -1308,13 +1308,17 @@ static int winShmSystemLock(
return rc;
}
/* Forward references to VFS methods */
static int winOpen(sqlite3_vfs*,const char*,sqlite3_file*,int,int*);
static int winDelete(sqlite3_vfs *,const char*,int);
/*
** Purge the winShmNodeList list of all entries with winShmNode.nRef==0.
**
** This is not a VFS shared-memory method; it is a utility function called
** by VFS shared-memory methods.
*/
static void winShmPurge(void){
static void winShmPurge(sqlite3_vfs *pVfs, int deleteFlag){
winShmNode **pp;
winShmNode *p;
assert( winShmMutexHeld() );
@@ -1332,6 +1336,7 @@ static void winShmPurge(void){
if( p->hFile.h != INVALID_HANDLE_VALUE ) {
winClose((sqlite3_file *)&p->hFile);
}
if( deleteFlag ) winDelete(pVfs, p->zFilename, 0);
*pp = p->pNext;
sqlite3_free(p);
}else{
@@ -1340,10 +1345,6 @@ static void winShmPurge(void){
}
}
/* Forward references to VFS methods */
static int winOpen(sqlite3_vfs*,const char*,sqlite3_file*,int,int*);
static int winDelete(sqlite3_vfs *,const char*,int);
/*
** Open a shared-memory area. This particular implementation uses
** mmapped files.
@@ -1457,7 +1458,7 @@ static int winShmOpen(
/* Jump here on any error */
shm_open_err:
winShmSystemLock(pShmNode, _SHM_UNLCK, WIN_SHM_DMS, 1);
winShmPurge(); /* This call frees pShmNode if required */
winShmPurge(pDbFd->pVfs, 0); /* This call frees pShmNode if required */
sqlite3_free(p);
sqlite3_free(pNew);
winShmLeaveMutex();
@@ -1498,8 +1499,7 @@ static int winShmClose(
assert( pShmNode->nRef>0 );
pShmNode->nRef--;
if( pShmNode->nRef==0 ){
if( deleteFlag ) winDelete(pDbFd->pVfs, pShmNode->zFilename, 0);
winShmPurge();
winShmPurge(pDbFd->pVfs, deleteFlag);
}
winShmLeaveMutex();