mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Comment and function naming tweaks to pcache. No functionality changes. (CVS 5572)
FossilOrigin-Name: 4b0e67d397236c740bea88ad3a5912abe896322a
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Modify\sthe\slemon\sparser\stemplate\sto\savoid\susing\szero-initialized\sconstants\nwhen\scompiled\swith\sC++.\s\sTicket\s#3288.\s(CVS\s5571)
|
C Comment\sand\sfunction\snaming\stweaks\sto\spcache.\s\sNo\sfunctionality\schanges.\s(CVS\s5572)
|
||||||
D 2008-08-20T17:48:21
|
D 2008-08-20T21:47:46
|
||||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||||
F Makefile.in 0b1c022000f55221454a7846022f11674d8024bf
|
F Makefile.in 0b1c022000f55221454a7846022f11674d8024bf
|
||||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||||
@@ -135,10 +135,10 @@ F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
|
|||||||
F src/os_os2.c 676ed273b17bd260f905df81375c9f9950d85517
|
F src/os_os2.c 676ed273b17bd260f905df81375c9f9950d85517
|
||||||
F src/os_unix.c fe0dbc35bcd3de49e46b132abfc0f45d6dd6a864
|
F src/os_unix.c fe0dbc35bcd3de49e46b132abfc0f45d6dd6a864
|
||||||
F src/os_win.c aefe9ee26430678a19a058a874e4e2bd91398142
|
F src/os_win.c aefe9ee26430678a19a058a874e4e2bd91398142
|
||||||
F src/pager.c 9f813a8f26680ff510335e2bbd01910b2a77277b
|
F src/pager.c 79d4d33245462c054a7e815e29ec6500c667ef26
|
||||||
F src/pager.h fb9376af5ba8e1eb78ee3b4f15eb0f60658ffd65
|
F src/pager.h fb9376af5ba8e1eb78ee3b4f15eb0f60658ffd65
|
||||||
F src/parse.y d0f76d2cb8d6883d5600dc20beb961a6022b94b8
|
F src/parse.y d0f76d2cb8d6883d5600dc20beb961a6022b94b8
|
||||||
F src/pcache.c c1a9abb5e2aa3d1d52a2995c8e0a36535d4d1bc2
|
F src/pcache.c cf7a7c81366e42330ff9c84d1f3591c905289c3d
|
||||||
F src/pcache.h 71ade7a84ed87d9d20507315260b1d91808d7c9a
|
F src/pcache.h 71ade7a84ed87d9d20507315260b1d91808d7c9a
|
||||||
F src/pragma.c f5b271b090af7fcedd308d7c5807a5503f7a853d
|
F src/pragma.c f5b271b090af7fcedd308d7c5807a5503f7a853d
|
||||||
F src/prepare.c c197041e0c4770672cda75e6bfe10242f885e510
|
F src/prepare.c c197041e0c4770672cda75e6bfe10242f885e510
|
||||||
@@ -623,7 +623,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
|||||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||||
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
|
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
|
||||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||||
P aef5b909e960c31527c795bc09a1de846f8afcbb
|
P 71992f4a3723418df5f16093aec92f1f95f0b604
|
||||||
R ba6058aa52b7f536a969626105129ff5
|
R 1864568c91564440b5d8de8411bca79f
|
||||||
U drh
|
U drh
|
||||||
Z a81a89f6460671859f4d4500f7e3aaad
|
Z 8ae3b66a71a20677fcd2b2a4e9762a73
|
||||||
|
@@ -1 +1 @@
|
|||||||
71992f4a3723418df5f16093aec92f1f95f0b604
|
4b0e67d397236c740bea88ad3a5912abe896322a
|
@@ -18,7 +18,7 @@
|
|||||||
** file simultaneously, or one process from reading the database while
|
** file simultaneously, or one process from reading the database while
|
||||||
** another is writing.
|
** another is writing.
|
||||||
**
|
**
|
||||||
** @(#) $Id: pager.c,v 1.470 2008/08/20 14:49:24 danielk1977 Exp $
|
** @(#) $Id: pager.c,v 1.471 2008/08/20 21:47:46 drh Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef SQLITE_OMIT_DISKIO
|
#ifndef SQLITE_OMIT_DISKIO
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
@@ -490,7 +490,7 @@ static void checkPage(PgHdr *pPg){
|
|||||||
#define pager_datahash(X,Y) 0
|
#define pager_datahash(X,Y) 0
|
||||||
#define pager_pagehash(X) 0
|
#define pager_pagehash(X) 0
|
||||||
#define CHECK_PAGE(x)
|
#define CHECK_PAGE(x)
|
||||||
#endif
|
#endif /* SQLITE_CHECK_PAGES */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** When this is called the journal file for pager pPager must be open.
|
** When this is called the journal file for pager pPager must be open.
|
||||||
@@ -1868,7 +1868,8 @@ int sqlite3PagerOpen(
|
|||||||
return ((rc==SQLITE_OK)?SQLITE_NOMEM:rc);
|
return ((rc==SQLITE_OK)?SQLITE_NOMEM:rc);
|
||||||
}
|
}
|
||||||
nExtra = FORCE_ALIGNMENT(nExtra);
|
nExtra = FORCE_ALIGNMENT(nExtra);
|
||||||
sqlite3PcacheOpen(szPageDflt, nExtra, !memDb, xDesc, !memDb?pagerStress:0, (void *)pPager, pPager->pPCache);
|
sqlite3PcacheOpen(szPageDflt, nExtra, !memDb, xDesc,
|
||||||
|
!memDb?pagerStress:0, (void *)pPager, pPager->pPCache);
|
||||||
|
|
||||||
PAGERTRACE3("OPEN %d %s\n", FILEHANDLEID(pPager->fd), pPager->zFilename);
|
PAGERTRACE3("OPEN %d %s\n", FILEHANDLEID(pPager->fd), pPager->zFilename);
|
||||||
IOTRACE(("OPEN %p %s\n", pPager, pPager->zFilename))
|
IOTRACE(("OPEN %p %s\n", pPager, pPager->zFilename))
|
||||||
|
115
src/pcache.c
115
src/pcache.c
@@ -11,7 +11,7 @@
|
|||||||
*************************************************************************
|
*************************************************************************
|
||||||
** This file implements that page cache.
|
** This file implements that page cache.
|
||||||
**
|
**
|
||||||
** @(#) $Id: pcache.c,v 1.1 2008/08/20 14:49:25 danielk1977 Exp $
|
** @(#) $Id: pcache.c,v 1.2 2008/08/20 21:47:46 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ static struct PCacheGlobal {
|
|||||||
PCache *pAll; /* list of all page caches */
|
PCache *pAll; /* list of all page caches */
|
||||||
int nPage; /* Number of pages */
|
int nPage; /* Number of pages */
|
||||||
int nPurgeable; /* Number of pages in purgable caches */
|
int nPurgeable; /* Number of pages in purgable caches */
|
||||||
int mxPage; /* Globally configured page maximum */
|
int mxPage; /* Globally configured page maximum */
|
||||||
int mxPagePurgeable; /* Purgeable page maximum */
|
int mxPagePurgeable; /* Purgeable page maximum */
|
||||||
PgHdr *pLruHead, *pLruTail; /* Global LRU list of unused pages */
|
PgHdr *pLruHead, *pLruTail; /* Global LRU list of unused pages */
|
||||||
int szSlot; /* Size of each free slot */
|
int szSlot; /* Size of each free slot */
|
||||||
@@ -99,13 +99,13 @@ static struct PCacheGlobal {
|
|||||||
** mutex released (in that order) before making the call.
|
** mutex released (in that order) before making the call.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define enterPcacheGlobal() sqlite3_mutex_enter(pcache.mutex_lru)
|
#define pcacheEnterGlobal() sqlite3_mutex_enter(pcache.mutex_lru)
|
||||||
#define exitPcacheGlobal() sqlite3_mutex_leave(pcache.mutex_lru)
|
#define pcacheExitGlobal() sqlite3_mutex_leave(pcache.mutex_lru)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Increment the reference count on both page p and its cache by n.
|
** Increment the reference count on both page p and its cache by n.
|
||||||
*/
|
*/
|
||||||
static void page_ref(PgHdr *p, int n){
|
static void pcacheRef(PgHdr *p, int n){
|
||||||
/* This next block assert()s that the number of references to the
|
/* This next block assert()s that the number of references to the
|
||||||
** PCache is the sum of the number of references to all pages in
|
** PCache is the sum of the number of references to all pages in
|
||||||
** the PCache. This is a bit expensive to leave turned on all the
|
** the PCache. This is a bit expensive to leave turned on all the
|
||||||
@@ -124,7 +124,13 @@ static void page_ref(PgHdr *p, int n){
|
|||||||
|
|
||||||
/********************************** Linked List Management ********************/
|
/********************************** Linked List Management ********************/
|
||||||
|
|
||||||
static int check_hash_count(PCache *pCache){
|
#ifndef NDEBUG
|
||||||
|
/*
|
||||||
|
** This routine verifies that the number of entries in the hash table
|
||||||
|
** is pCache->nPage. This routine is used within assert() statements
|
||||||
|
** only and is therefore disabled during production builds.
|
||||||
|
*/
|
||||||
|
static int pcacheCheckHashCount(PCache *pCache){
|
||||||
int i;
|
int i;
|
||||||
int nPage = 0;
|
int nPage = 0;
|
||||||
for(i=0; i<pCache->nHash; i++){
|
for(i=0; i<pCache->nHash; i++){
|
||||||
@@ -136,6 +142,7 @@ static int check_hash_count(PCache *pCache){
|
|||||||
assert( nPage==pCache->nPage );
|
assert( nPage==pCache->nPage );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Remove a page from its hash table (PCache.apHash[]).
|
** Remove a page from its hash table (PCache.apHash[]).
|
||||||
@@ -153,7 +160,7 @@ static void pcacheRemoveFromHash(PgHdr *pPage){
|
|||||||
pPage->pNextHash->pPrevHash = pPage->pPrevHash;
|
pPage->pNextHash->pPrevHash = pPage->pPrevHash;
|
||||||
}
|
}
|
||||||
pPage->pCache->nPage--;
|
pPage->pCache->nPage--;
|
||||||
assert( check_hash_count(pPage->pCache) );
|
assert( pcacheCheckHashCount(pPage->pCache) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -169,21 +176,22 @@ static void pcacheAddToHash(PgHdr *pPage){
|
|||||||
}
|
}
|
||||||
pCache->apHash[h] = pPage;
|
pCache->apHash[h] = pPage;
|
||||||
pCache->nPage++;
|
pCache->nPage++;
|
||||||
assert( check_hash_count(pCache) );
|
assert( pcacheCheckHashCount(pCache) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Resize the hash table to nHash buckets.
|
** Attempt to increase the size the hash table to contain
|
||||||
|
** at least nHash buckets.
|
||||||
*/
|
*/
|
||||||
static int pcacheResizeHash(PCache *pCache, int nHash){
|
static int pcacheResizeHash(PCache *pCache, int nHash){
|
||||||
#ifdef SQLITE_MALLOC_SOFT_LIMIT
|
#ifdef SQLITE_MALLOC_SOFT_LIMIT
|
||||||
if( nHash*sizeof(PgHdr *)>SQLITE_MALLOC_SOFT_LIMIT ){
|
if( nHash*sizeof(PgHdr*)>SQLITE_MALLOC_SOFT_LIMIT ){
|
||||||
nHash = SQLITE_MALLOC_SOFT_LIMIT/sizeof(PgHdr *);
|
nHash = SQLITE_MALLOC_SOFT_LIMIT/sizeof(PgHdr *);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if( nHash>pCache->nHash ){
|
if( nHash>pCache->nHash ){
|
||||||
PgHdr *p;
|
PgHdr *p;
|
||||||
PgHdr **pNew = (PgHdr **)sqlite3_malloc(sizeof(PgHdr *)*nHash);
|
PgHdr **pNew = (PgHdr **)sqlite3_malloc(sizeof(PgHdr*)*nHash);
|
||||||
if( !pNew ){
|
if( !pNew ){
|
||||||
return SQLITE_NOMEM;
|
return SQLITE_NOMEM;
|
||||||
}
|
}
|
||||||
@@ -333,9 +341,9 @@ void *pcacheMalloc(int sz){
|
|||||||
}
|
}
|
||||||
void *sqlite3PageMalloc(sz){
|
void *sqlite3PageMalloc(sz){
|
||||||
void *p;
|
void *p;
|
||||||
enterPcacheGlobal();
|
pcacheEnterGlobal();
|
||||||
p = pcacheMalloc(sz);
|
p = pcacheMalloc(sz);
|
||||||
exitPcacheGlobal();
|
pcacheExitGlobal();
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,9 +366,9 @@ void pcacheFree(void *p){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void sqlite3PageFree(void *p){
|
void sqlite3PageFree(void *p){
|
||||||
enterPcacheGlobal();
|
pcacheEnterGlobal();
|
||||||
pcacheFree(p);
|
pcacheFree(p);
|
||||||
exitPcacheGlobal();
|
pcacheExitGlobal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -415,7 +423,7 @@ static PgHdr *pcacheRecycleOrAlloc(PCache *pCache){
|
|||||||
assert( pcache.isInit );
|
assert( pcache.isInit );
|
||||||
assert( sqlite3_mutex_notheld(pcache.mutex_lru) );
|
assert( sqlite3_mutex_notheld(pcache.mutex_lru) );
|
||||||
|
|
||||||
enterPcacheGlobal();
|
pcacheEnterGlobal();
|
||||||
|
|
||||||
if( (pcache.mxPage && pcache.nPage>=pcache.mxPage)
|
if( (pcache.mxPage && pcache.nPage>=pcache.mxPage)
|
||||||
|| (!pcache.mxPage && bPurg && pcache.nPurgeable>=pcache.mxPagePurgeable)
|
|| (!pcache.mxPage && bPurg && pcache.nPurgeable>=pcache.mxPagePurgeable)
|
||||||
@@ -435,9 +443,9 @@ static PgHdr *pcacheRecycleOrAlloc(PCache *pCache){
|
|||||||
assert( pCsr->iInUseMM==0 );
|
assert( pCsr->iInUseMM==0 );
|
||||||
pCsr->iInUseMM = 1;
|
pCsr->iInUseMM = 1;
|
||||||
if( pCsr->xStress && (pCsr->iInUseDB==0 || pCache==pCsr) ){
|
if( pCsr->xStress && (pCsr->iInUseDB==0 || pCache==pCsr) ){
|
||||||
exitPcacheGlobal();
|
pcacheExitGlobal();
|
||||||
pCsr->xStress(pCsr->pStress);
|
pCsr->xStress(pCsr->pStress);
|
||||||
enterPcacheGlobal();
|
pcacheEnterGlobal();
|
||||||
}
|
}
|
||||||
pCsr->iInUseMM = 0;
|
pCsr->iInUseMM = 0;
|
||||||
}
|
}
|
||||||
@@ -472,7 +480,7 @@ static PgHdr *pcacheRecycleOrAlloc(PCache *pCache){
|
|||||||
p = pcachePageAlloc(szPage, szExtra, bPurg);
|
p = pcachePageAlloc(szPage, szExtra, bPurg);
|
||||||
}
|
}
|
||||||
|
|
||||||
exitPcacheGlobal();
|
pcacheExitGlobal();
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -527,9 +535,9 @@ void sqlite3PcacheOpen(
|
|||||||
p->nMax = 100;
|
p->nMax = 100;
|
||||||
|
|
||||||
if( bPurgeable ){
|
if( bPurgeable ){
|
||||||
enterPcacheGlobal();
|
pcacheEnterGlobal();
|
||||||
pcache.mxPagePurgeable += p->nMax;
|
pcache.mxPagePurgeable += p->nMax;
|
||||||
exitPcacheGlobal();
|
pcacheExitGlobal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add the new pager-cache to the list of caches starting at pcache.pAll */
|
/* Add the new pager-cache to the list of caches starting at pcache.pAll */
|
||||||
@@ -543,6 +551,10 @@ void sqlite3PcacheOpen(
|
|||||||
sqlite3_mutex_leave(pcache.mutex_mem2);
|
sqlite3_mutex_leave(pcache.mutex_mem2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Change the page size for PCache object. This can only happen
|
||||||
|
** when the cache is empty.
|
||||||
|
*/
|
||||||
void sqlite3PcacheSetPageSize(PCache *pCache, int szPage){
|
void sqlite3PcacheSetPageSize(PCache *pCache, int szPage){
|
||||||
assert(pCache->nPage==0);
|
assert(pCache->nPage==0);
|
||||||
pCache->szPage = szPage;
|
pCache->szPage = szPage;
|
||||||
@@ -569,11 +581,11 @@ int sqlite3PcacheFetch(
|
|||||||
for(pPage=pCache->apHash[h]; pPage; pPage=pPage->pNextHash){
|
for(pPage=pCache->apHash[h]; pPage; pPage=pPage->pNextHash){
|
||||||
if( pPage->pgno==pgno ){
|
if( pPage->pgno==pgno ){
|
||||||
if( pPage->nRef==0 && (pPage->flags & PGHDR_DIRTY)==0 ){
|
if( pPage->nRef==0 && (pPage->flags & PGHDR_DIRTY)==0 ){
|
||||||
enterPcacheGlobal();
|
pcacheEnterGlobal();
|
||||||
pcacheRemoveFromLruList(pPage);
|
pcacheRemoveFromLruList(pPage);
|
||||||
exitPcacheGlobal();
|
pcacheExitGlobal();
|
||||||
}
|
}
|
||||||
page_ref(pPage, 1);
|
pcacheRef(pPage, 1);
|
||||||
*ppPage = pPage;
|
*ppPage = pPage;
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
@@ -600,7 +612,7 @@ int sqlite3PcacheFetch(
|
|||||||
pPage->nRef = 0;
|
pPage->nRef = 0;
|
||||||
pPage->pgno = pgno;
|
pPage->pgno = pgno;
|
||||||
pPage->pCache = pCache;
|
pPage->pCache = pCache;
|
||||||
page_ref(pPage, 1);
|
pcacheRef(pPage, 1);
|
||||||
pcacheAddToList(&pCache->pClean, pPage);
|
pcacheAddToList(&pCache->pClean, pPage);
|
||||||
pcacheAddToHash(pPage);
|
pcacheAddToHash(pPage);
|
||||||
}else{
|
}else{
|
||||||
@@ -617,20 +629,20 @@ int sqlite3PcacheFetch(
|
|||||||
void sqlite3PcacheRelease(PgHdr *p){
|
void sqlite3PcacheRelease(PgHdr *p){
|
||||||
assert( p->nRef>0 );
|
assert( p->nRef>0 );
|
||||||
assert( p->pCache->iInUseDB || p->pCache->iInUseMM );
|
assert( p->pCache->iInUseDB || p->pCache->iInUseMM );
|
||||||
page_ref(p, -1);
|
pcacheRef(p, -1);
|
||||||
if( p->nRef!=0 ) return;
|
if( p->nRef!=0 ) return;
|
||||||
if( p->pCache->xDestroy ){
|
if( p->pCache->xDestroy ){
|
||||||
p->pCache->xDestroy(p);
|
p->pCache->xDestroy(p);
|
||||||
}
|
}
|
||||||
if( (p->flags & PGHDR_DIRTY)!=0 ) return;
|
if( (p->flags & PGHDR_DIRTY)!=0 ) return;
|
||||||
enterPcacheGlobal();
|
pcacheEnterGlobal();
|
||||||
pcacheAddToLruList(p);
|
pcacheAddToLruList(p);
|
||||||
exitPcacheGlobal();
|
pcacheExitGlobal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sqlite3PcacheRef(PgHdr *p){
|
void sqlite3PcacheRef(PgHdr *p){
|
||||||
assert(p->nRef>=0);
|
assert(p->nRef>=0);
|
||||||
page_ref(p, 1);
|
pcacheRef(p, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -649,9 +661,9 @@ void sqlite3PcacheDrop(PgHdr *p){
|
|||||||
pcacheRemoveFromList(&pCache->pClean, p);
|
pcacheRemoveFromList(&pCache->pClean, p);
|
||||||
}
|
}
|
||||||
pcacheRemoveFromHash(p);
|
pcacheRemoveFromHash(p);
|
||||||
enterPcacheGlobal();
|
pcacheEnterGlobal();
|
||||||
pcachePageFree(p);
|
pcachePageFree(p);
|
||||||
exitPcacheGlobal();
|
pcacheExitGlobal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -686,9 +698,9 @@ void sqlite3PcacheMakeClean(PgHdr *p){
|
|||||||
pcacheAddToList(&pCache->pClean, p);
|
pcacheAddToList(&pCache->pClean, p);
|
||||||
p->flags &= ~PGHDR_DIRTY;
|
p->flags &= ~PGHDR_DIRTY;
|
||||||
if( p->nRef==0 ){
|
if( p->nRef==0 ){
|
||||||
enterPcacheGlobal();
|
pcacheEnterGlobal();
|
||||||
pcacheAddToLruList(p);
|
pcacheAddToLruList(p);
|
||||||
exitPcacheGlobal();
|
pcacheExitGlobal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -704,9 +716,9 @@ void sqlite3PcacheCleanAll(PCache *pCache){
|
|||||||
pcacheAddToList(&pCache->pClean, p);
|
pcacheAddToList(&pCache->pClean, p);
|
||||||
p->flags &= ~PGHDR_DIRTY;
|
p->flags &= ~PGHDR_DIRTY;
|
||||||
if( p->nRef==0 ){
|
if( p->nRef==0 ){
|
||||||
enterPcacheGlobal();
|
pcacheEnterGlobal();
|
||||||
pcacheAddToLruList(p);
|
pcacheAddToLruList(p);
|
||||||
exitPcacheGlobal();
|
pcacheExitGlobal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -722,10 +734,10 @@ void sqlite3PcacheMove(PgHdr *p, Pgno newPgno){
|
|||||||
p->pgno = newPgno;
|
p->pgno = newPgno;
|
||||||
if( newPgno==0 ){
|
if( newPgno==0 ){
|
||||||
p->flags |= PGHDR_REUSE_UNLIKELY;
|
p->flags |= PGHDR_REUSE_UNLIKELY;
|
||||||
enterPcacheGlobal();
|
pcacheEnterGlobal();
|
||||||
pcacheFree(p->apSave[0]);
|
pcacheFree(p->apSave[0]);
|
||||||
pcacheFree(p->apSave[1]);
|
pcacheFree(p->apSave[1]);
|
||||||
exitPcacheGlobal();
|
pcacheExitGlobal();
|
||||||
p->apSave[0] = 0;
|
p->apSave[0] = 0;
|
||||||
p->apSave[1] = 0;
|
p->apSave[1] = 0;
|
||||||
sqlite3PcacheMakeClean(p);
|
sqlite3PcacheMakeClean(p);
|
||||||
@@ -737,9 +749,9 @@ void sqlite3PcacheMove(PgHdr *p, Pgno newPgno){
|
|||||||
** Set the global maximum number of pages. Return the previous value.
|
** Set the global maximum number of pages. Return the previous value.
|
||||||
*/
|
*/
|
||||||
void sqlite3PcacheGlobalMax(int mx){
|
void sqlite3PcacheGlobalMax(int mx){
|
||||||
enterPcacheGlobal();
|
pcacheEnterGlobal();
|
||||||
pcache.mxPage = mx;
|
pcache.mxPage = mx;
|
||||||
exitPcacheGlobal();
|
pcacheExitGlobal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -771,7 +783,7 @@ void sqlite3PcacheTruncate(PCache *pCache, Pgno pgno){
|
|||||||
PgHdr *p, *pNext;
|
PgHdr *p, *pNext;
|
||||||
PgHdr *pDirty = pCache->pDirty;
|
PgHdr *pDirty = pCache->pDirty;
|
||||||
assert( pCache->iInUseDB );
|
assert( pCache->iInUseDB );
|
||||||
enterPcacheGlobal();
|
pcacheEnterGlobal();
|
||||||
for(p=pCache->pClean; p||pDirty; p=pNext){
|
for(p=pCache->pClean; p||pDirty; p=pNext){
|
||||||
if( !p ){
|
if( !p ){
|
||||||
p = pDirty;
|
p = pDirty;
|
||||||
@@ -796,7 +808,7 @@ void sqlite3PcacheTruncate(PCache *pCache, Pgno pgno){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exitPcacheGlobal();
|
pcacheExitGlobal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -809,13 +821,13 @@ void sqlite3PcacheClose(PCache *pCache){
|
|||||||
/* Free all the pages used by this pager and remove them from the LRU
|
/* Free all the pages used by this pager and remove them from the LRU
|
||||||
** list. This requires the protection of the MUTEX_STATIC_LRU mutex.
|
** list. This requires the protection of the MUTEX_STATIC_LRU mutex.
|
||||||
*/
|
*/
|
||||||
enterPcacheGlobal();
|
pcacheEnterGlobal();
|
||||||
pcacheClear(pCache);
|
pcacheClear(pCache);
|
||||||
if( pCache->bPurgeable ){
|
if( pCache->bPurgeable ){
|
||||||
pcache.mxPagePurgeable -= pCache->nMax;
|
pcache.mxPagePurgeable -= pCache->nMax;
|
||||||
}
|
}
|
||||||
sqlite3_free(pCache->apHash);
|
sqlite3_free(pCache->apHash);
|
||||||
exitPcacheGlobal();
|
pcacheExitGlobal();
|
||||||
|
|
||||||
/* Now remove the pager-cache structure itself from the list of
|
/* Now remove the pager-cache structure itself from the list of
|
||||||
** all such structures headed by pcache.pAll. This required the
|
** all such structures headed by pcache.pAll. This required the
|
||||||
@@ -865,14 +877,14 @@ int sqlite3PcachePreserve(PgHdr *p, int idJournal){
|
|||||||
void sqlite3PcacheCommit(PCache *pCache, int idJournal){
|
void sqlite3PcacheCommit(PCache *pCache, int idJournal){
|
||||||
PgHdr *p;
|
PgHdr *p;
|
||||||
assert( pCache->iInUseDB );
|
assert( pCache->iInUseDB );
|
||||||
enterPcacheGlobal(); /* Mutex is required to call pcacheFree() */
|
pcacheEnterGlobal(); /* Mutex is required to call pcacheFree() */
|
||||||
for(p=pCache->pDirty; p; p=p->pNext){
|
for(p=pCache->pDirty; p; p=p->pNext){
|
||||||
if( p->apSave[idJournal] ){
|
if( p->apSave[idJournal] ){
|
||||||
pcacheFree(p->apSave[idJournal]);
|
pcacheFree(p->apSave[idJournal]);
|
||||||
p->apSave[idJournal] = 0;
|
p->apSave[idJournal] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exitPcacheGlobal();
|
pcacheExitGlobal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -882,7 +894,7 @@ void sqlite3PcacheRollback(PCache *pCache, int idJournal){
|
|||||||
PgHdr *p;
|
PgHdr *p;
|
||||||
int sz;
|
int sz;
|
||||||
assert( pCache->iInUseDB );
|
assert( pCache->iInUseDB );
|
||||||
enterPcacheGlobal(); /* Mutex is required to call pcacheFree() */
|
pcacheEnterGlobal(); /* Mutex is required to call pcacheFree() */
|
||||||
sz = pCache->szPage;
|
sz = pCache->szPage;
|
||||||
for(p=pCache->pDirty; p; p=p->pNext){
|
for(p=pCache->pDirty; p; p=p->pNext){
|
||||||
if( p->apSave[idJournal] ){
|
if( p->apSave[idJournal] ){
|
||||||
@@ -891,7 +903,7 @@ void sqlite3PcacheRollback(PCache *pCache, int idJournal){
|
|||||||
p->apSave[idJournal] = 0;
|
p->apSave[idJournal] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exitPcacheGlobal();
|
pcacheExitGlobal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -916,9 +928,9 @@ void sqlite3PcacheAssertFlags(PCache *pCache, int trueMask, int falseMask){
|
|||||||
int sqlite3PcacheClear(PCache *pCache){
|
int sqlite3PcacheClear(PCache *pCache){
|
||||||
assert( pCache->iInUseDB );
|
assert( pCache->iInUseDB );
|
||||||
assert(pCache->nRef==0);
|
assert(pCache->nRef==0);
|
||||||
enterPcacheGlobal();
|
pcacheEnterGlobal();
|
||||||
pcacheClear(pCache);
|
pcacheClear(pCache);
|
||||||
exitPcacheGlobal();
|
pcacheExitGlobal();
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1100,10 +1112,10 @@ void sqlite3PcacheSetCachesize(PCache *pCache, int mxPage){
|
|||||||
mxPage = 10;
|
mxPage = 10;
|
||||||
}
|
}
|
||||||
if( pCache->bPurgeable ){
|
if( pCache->bPurgeable ){
|
||||||
enterPcacheGlobal();
|
pcacheEnterGlobal();
|
||||||
pcache.mxPagePurgeable -= pCache->nMax;
|
pcache.mxPagePurgeable -= pCache->nMax;
|
||||||
pcache.mxPagePurgeable += mxPage;
|
pcache.mxPagePurgeable += mxPage;
|
||||||
exitPcacheGlobal();
|
pcacheExitGlobal();
|
||||||
}
|
}
|
||||||
pCache->nMax = mxPage;
|
pCache->nMax = mxPage;
|
||||||
}
|
}
|
||||||
@@ -1129,4 +1141,3 @@ void sqlite3PcacheUnlock(PCache *pCache){
|
|||||||
pCache->iInUseDB--;
|
pCache->iInUseDB--;
|
||||||
assert( pCache->iInUseDB>=0 );
|
assert( pCache->iInUseDB>=0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user