diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/os_win.c | 3 | ||||
-rw-r--r-- | src/pcache.c | 12 | ||||
-rw-r--r-- | src/pcache1.c | 19 |
3 files changed, 10 insertions, 24 deletions
diff --git a/src/os_win.c b/src/os_win.c index 2827b0b49..d71fb3922 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -5763,7 +5763,8 @@ static int winFullPathname( char *zFull /* Output buffer */ ){ int rc; - sqlite3_mutex *pMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR); + MUTEX_LOGIC( sqlite3_mutex *pMutex; ) + MUTEX_LOGIC( pMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR); ) sqlite3_mutex_enter(pMutex); rc = winFullPathnameNoMutex(pVfs, zRelative, nFull, zFull); sqlite3_mutex_leave(pMutex); diff --git a/src/pcache.c b/src/pcache.c index 8c57f5b1e..0407e06b2 100644 --- a/src/pcache.c +++ b/src/pcache.c @@ -655,14 +655,14 @@ void sqlite3PcacheMove(PgHdr *p, Pgno newPgno){ assert( sqlite3PcachePageSanity(p) ); pcacheTrace(("%p.MOVE %d -> %d\n",pCache,p->pgno,newPgno)); pOther = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, newPgno, 0); - sqlite3GlobalConfig.pcache2.xRekey(pCache->pCache, p->pPage, p->pgno,newPgno); if( pOther ){ - PgHdr *pPg = (PgHdr*)pOther->pExtra; - pPg->pgno = p->pgno; - if( pPg->pPage==0 ){ - sqlite3GlobalConfig.pcache2.xUnpin(pCache->pCache, pOther, 0); - } + PgHdr *pXPage = (PgHdr*)pOther->pExtra; + assert( pXPage->nRef==0 ); + pXPage->nRef++; + pCache->nRefSum++; + sqlite3PcacheDrop(pXPage); } + sqlite3GlobalConfig.pcache2.xRekey(pCache->pCache, p->pPage, p->pgno,newPgno); p->pgno = newPgno; if( (p->flags&PGHDR_DIRTY) && (p->flags&PGHDR_NEED_SYNC) ){ pcacheManageDirtyList(p, PCACHE_DIRTYLIST_FRONT); diff --git a/src/pcache1.c b/src/pcache1.c index a47087fa1..adbe95395 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -1125,7 +1125,7 @@ static void pcache1Rekey( assert( iOld!=iNew ); /* The page number really is changing */ pcache1EnterMutex(pCache->pGroup); - + assert( pcache1FetchNoMutex(p, iOld, 0)==pPage ); /* pPg really is iOld */ hOld = iOld%pCache->nHash; pp = &pCache->apHash[hOld]; @@ -1134,23 +1134,8 @@ static void pcache1Rekey( } *pp = pPage->pNext; + assert( pcache1FetchNoMutex(p, iNew, 0)==0 ); /* iNew not in cache */ hNew = iNew%pCache->nHash; - pp = &pCache->apHash[hNew]; - while( *pp ){ - if( (*pp)->iKey==iNew ){ - /* If there is already another pcache entry at iNew, change it to iOld, - ** thus swapping the positions of iNew and iOld */ - PgHdr1 *pOld = *pp; - *pp = pOld->pNext; - pOld->pNext = pCache->apHash[hOld]; - pCache->apHash[hOld] = pOld; - pOld->iKey = iOld; - break; - }else{ - pp = &(*pp)->pNext; - } - } - pPage->iKey = iNew; pPage->pNext = pCache->apHash[hNew]; pCache->apHash[hNew] = pPage; |