]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Remove unreachable branches from pcache.c. (CVS 5620)
authordanielk1977 <danielk1977@noemail.net>
Wed, 27 Aug 2008 09:44:39 +0000 (09:44 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Wed, 27 Aug 2008 09:44:39 +0000 (09:44 +0000)
FossilOrigin-Name: 7de32498b349e046c5c886de255bbdefd6a7e8f7

manifest
manifest.uuid
src/pager.c
src/pcache.c

index 1f2aed69e7846f3f50cf96cd5cb52dc87821c0ef..aa9f67b87885a39f2c10b00df434ad0d6d0c2785 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\san\sissue\swith\sthe\spermutation\stest\sscript.\s(CVS\s5619)
-D 2008-08-26T23:08:04
+C Remove\sunreachable\sbranches\sfrom\spcache.c.\s(CVS\s5620)
+D 2008-08-27T09:44:40
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 689e14735f862a5553bceef206d8c13e29504e44
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -135,10 +135,10 @@ F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
 F src/os_os2.c e391fc95adc744bbdcefd4d11e3066998185a0a0
 F src/os_unix.c 4665cef7639dd937893c3ea076f0e8a8f215bb32
 F src/os_win.c aefe9ee26430678a19a058a874e4e2bd91398142
-F src/pager.c 66836244eac6b1a46e8c26e3dd3c143031bf28e5
+F src/pager.c 095efa75a1a6500e6e975d1f7ddad34ed25424ae
 F src/pager.h 3b9c138d2e744b9d6e61d4c2742301e3bf464864
 F src/parse.y d0f76d2cb8d6883d5600dc20beb961a6022b94b8
-F src/pcache.c 006714ad89db3c488526246e6ed6b130e457f01b
+F src/pcache.c 9e00544dd8c2bc93087050fecad9767353a9b81d
 F src/pcache.h 3531f83e1771442af16f6ffeac68024ff8c8bb2d
 F src/pragma.c f5b271b090af7fcedd308d7c5807a5503f7a853d
 F src/prepare.c c197041e0c4770672cda75e6bfe10242f885e510
@@ -624,7 +624,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 7e1032ab0031ba535f37b6338a3ac81cb1449d76
-R 5bb8278c25d388f413885c21aaec9f08
-U drh
-Z 29c1240c9559901eefb07c5d9ddca3ab
+P 2e12aa3e078c0da9e418ff1f25a08f05cd03c07d
+R bd0a0c9cdd657d12dbda9e1d4a16eb2b
+U danielk1977
+Z b519f55ef9a51e1605788897feb7c282
index 8ee1ee756c90c62ba83548f0ae4e69f44556deae..4192ee715a7ff42ccd20fbe59df6d1ba0bcbc868 100644 (file)
@@ -1 +1 @@
-2e12aa3e078c0da9e418ff1f25a08f05cd03c07d
\ No newline at end of file
+7de32498b349e046c5c886de255bbdefd6a7e8f7
\ No newline at end of file
index ec4a9be5598d8c23614b2afae1467806460813f6..7d122aee0cc494aaafed6b864b125b9a2671ef40 100644 (file)
@@ -18,7 +18,7 @@
 ** file simultaneously, or one process from reading the database while
 ** another is writing.
 **
-** @(#) $Id: pager.c,v 1.481 2008/08/26 21:07:27 drh Exp $
+** @(#) $Id: pager.c,v 1.482 2008/08/27 09:44:40 danielk1977 Exp $
 */
 #ifndef SQLITE_OMIT_DISKIO
 #include "sqliteInt.h"
@@ -2825,10 +2825,6 @@ static int pagerAcquire(
   if( rc!=SQLITE_OK ){
     return rc;
   }
-  if( pPager->errCode && pPg->nRef==1 ){
-    sqlite3PcacheDrop(pPg);
-    return pPager->errCode;
-  }
   if( pPg->pPager==0 ){
     /* The pager cache has created a new page. Its content needs to 
     ** be initialized.
index 9e3c924ced34e743b0aeb5375da2ea7e8c443353..db2ec83b0256ca32549ae335b38901b2a8692a93 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** This file implements that page cache.
 **
-** @(#) $Id: pcache.c,v 1.15 2008/08/26 19:08:00 danielk1977 Exp $
+** @(#) $Id: pcache.c,v 1.16 2008/08/27 09:44:40 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 
@@ -518,7 +518,7 @@ static PgHdr *pcacheRecyclePage(){
 **
 ** Return a pointer to the new page, or NULL if an OOM condition occurs.
 */
-static PgHdr *pcacheRecycleOrAlloc(PCache *pCache){
+static int pcacheRecycleOrAlloc(PCache *pCache, PgHdr **ppPage){
   PgHdr *p = 0;
 
   int szPage = pCache->szPage;
@@ -527,6 +527,7 @@ static PgHdr *pcacheRecycleOrAlloc(PCache *pCache){
   assert( pcache.isInit );
   assert( sqlite3_mutex_notheld(pcache.mutex) );
 
+  *ppPage = 0;
   pcacheEnterGlobal();
 
   /* If we have reached the limit for pinned/dirty pages, and there is at
@@ -550,8 +551,12 @@ static PgHdr *pcacheRecycleOrAlloc(PCache *pCache){
       for(pPg=pCache->pDirtyTail; pPg && pPg->nRef; pPg=pPg->pPrev);
     }
     if( pPg ){
+      int rc;
       pcacheExitGlobal();
-      pCache->xStress(pCache->pStress, pPg);
+      rc = pCache->xStress(pCache->pStress, pPg);
+      if( rc!=SQLITE_OK ){
+        return rc;
+      }
       pcacheEnterGlobal();
     }
   }
@@ -572,7 +577,8 @@ static PgHdr *pcacheRecycleOrAlloc(PCache *pCache){
   }
 
   pcacheExitGlobal();
-  return p;
+  *ppPage = p;
+  return (p?SQLITE_OK:SQLITE_NOMEM);
 }
 
 /*************************************************** General Interfaces ******
@@ -584,10 +590,10 @@ int sqlite3PcacheInitialize(void){
   assert( pcache.isInit==0 );
   memset(&pcache, 0, sizeof(pcache));
   if( sqlite3Config.bCoreMutex ){
+    /* No need to check the return value of sqlite3_mutex_alloc(). 
+    ** Allocating a static mutex cannot fail.
+    */
     pcache.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU);
-    if( pcache.mutex==0 ){
-      return SQLITE_NOMEM;
-    }
   }
   pcache.isInit = 1;
   return SQLITE_OK;
@@ -680,19 +686,19 @@ int sqlite3PcacheFetch(
   }
 
   if( createFlag ){
+    int rc = SQLITE_OK;
     if( pCache->nHash<=pCache->nPage ){
-      int rc = pcacheResizeHash(pCache, pCache->nHash<256?256:pCache->nHash*2);
+      rc = pcacheResizeHash(pCache, pCache->nHash<256?256:pCache->nHash*2);
       if( rc!=SQLITE_OK ){
         return rc;
       }
     }
 
-    pPage = pcacheRecycleOrAlloc(pCache);
-    *ppPage = pPage;
-    if( pPage==0 ){
-      return SQLITE_NOMEM;
+    rc = pcacheRecycleOrAlloc(pCache, ppPage);
+    if( rc!=SQLITE_OK ){
+      return rc;
     }
-
+    pPage = *ppPage;
     pPage->pPager = 0;
     pPage->flags = 0;
     pPage->pDirty = 0;
@@ -743,20 +749,18 @@ void sqlite3PcacheRef(PgHdr *p){
 }
 
 /*
-** Drop a page from the cache.  This should be the only reference to
-** the page.
+** Drop a page from the cache. There must be exactly one reference to the
+** page. This function deletes that reference, so after it returns the
+** page pointed to by p is invalid.
 */
 void sqlite3PcacheDrop(PgHdr *p){
   PCache *pCache;
   assert( p->nRef==1 );
+  assert( 0==(p->flags&PGHDR_DIRTY) );
   pCache = p->pCache;
   pCache->nRef--;
   pCache->nPinned--;
-  if( p->flags & PGHDR_DIRTY ){
-    pcacheRemoveFromList(&pCache->pDirty, p);
-  }else{
-    pcacheRemoveFromList(&pCache->pClean, p);
-  }
+  pcacheRemoveFromList(&pCache->pClean, p);
   pcacheRemoveFromHash(p);
   pcacheEnterGlobal();
   pcachePageFree(p);
@@ -1140,11 +1144,8 @@ void sqlite3PcacheSetFlags(PCache *pCache, int andMask, int orMask){
   }
 
   if( 0==(andMask&PGHDR_NEED_SYNC) ){
-    PgHdr *pSynced = pCache->pDirtyTail;
-    while( pSynced && (pSynced->flags&PGHDR_NEED_SYNC) ){
-      pSynced = pSynced->pPrev;
-    }
-    pCache->pSynced = pSynced;
+    pCache->pSynced = pCache->pDirtyTail;
+    assert( !pCache->pSynced || (pCache->pSynced->flags&PGHDR_NEED_SYNC)==0 );
   }
 
   pcacheExitGlobal();