]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fixed store_rebuild handling of SWAP_LOG_DEL. Don't want to call
authorwessels <>
Sat, 7 Feb 1998 00:47:07 +0000 (00:47 +0000)
committerwessels <>
Sat, 7 Feb 1998 00:47:07 +0000 (00:47 +0000)
storeReleaseRequest() directly, because it won't free up the fileno
and other things.  Calling storeRelease will just call storeReleaseRequest.

Also don't write the ENTRY_SPECIAL entries to the swap.state log.

src/protos.h
src/store.cc
src/store_dir.cc
src/store_rebuild.cc

index 0d06ad6c794fb8e15a66fba60b258c95fbece5fb..6d1039dc2690a84e80a0d7f5031d9de45f8c65ec 100644 (file)
@@ -447,6 +447,7 @@ extern void storeAppendPrintf();
 #endif
 extern int storeCheckCachable(StoreEntry * e);
 extern void storeUnlinkFileno(int fileno);
+extern void storeSetPrivateKey(StoreEntry *);
 
 /*
  * store_log.c
index d63e0418db5c106b60673b59f52cef9f204f73e3..62ce8a6f2870375959786735d3211d4cef0bbd9d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.376 1998/02/04 23:41:00 wessels Exp $
+ * $Id: store.cc,v 1.377 1998/02/06 17:47:09 wessels Exp $
  *
  * DEBUG: section 20    Storeage Manager
  * AUTHOR: Harvest Derived
@@ -158,7 +158,6 @@ static void destroy_MemObject(StoreEntry *);
 static void destroy_MemObjectData(MemObject *);
 static void destroy_StoreEntry(StoreEntry *);
 static void storePurgeMem(StoreEntry *);
-static void storeSetPrivateKey(StoreEntry *);
 static unsigned int getKeyCounter(void);
 static int storeKeepInMemory(const StoreEntry *);
 
@@ -353,7 +352,7 @@ getKeyCounter(void)
     return key_counter;
 }
 
-static void
+void
 storeSetPrivateKey(StoreEntry * e)
 {
     const cache_key *newkey;
index 3ac9026553443fae65e867de642b93fdc37926bc..db444f47c51ad2000b3d8b87be1b80864228eb93 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir.cc,v 1.46 1998/02/04 23:41:02 wessels Exp $
+ * $Id: store_dir.cc,v 1.47 1998/02/06 17:47:11 wessels Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -280,6 +280,11 @@ storeDirSwapLog(const StoreEntry * e, int op)
        if (e->swap_file_number < 0)    /* was never swapped out */
            return;
     }
+    /*
+     * icons and such; don't write them to the swap log
+     */
+    if (EBIT_TEST(e->flag, ENTRY_SPECIAL))
+       return;
     s->op = (char) op;
     s->swap_file_number = e->swap_file_number;
     s->timestamp = e->timestamp;
@@ -535,6 +540,8 @@ storeDirWriteCleanLogs(int reopen)
            continue;
        if (EBIT_TEST(e->flag, KEY_PRIVATE))
            continue;
+       if (EBIT_TEST(e->flag, ENTRY_SPECIAL))
+           continue;
        dirn = storeDirNumber(e->swap_file_number);
        assert(dirn < Config.cacheSwap.n_configured);
        if (fd[dirn] < 0)
index f8da7ab46b35c60e4186ff0ac065f840c3044203..f753b3557ba67b952f3b29903f9bc63ef38520eb 100644 (file)
@@ -32,6 +32,7 @@ struct storeRebuildState {
     int statcount;             /* # entries from directory walking */
     int clashcount;            /* # swapfile clashes avoided */
     int dupcount;              /* # duplicates purged */
+    int cancelcount;           /* # SWAP_LOG_DEL objects purged */
     int invalid;               /* # bad lines */
     int badflags;              /* # bad e->flags */
     int need_to_validate;
@@ -204,8 +205,22 @@ storeRebuildFromSwapLog(rebuild_dir * d)
        if (s.op == SWAP_LOG_ADD) {
            (void) 0;
        } else if (s.op == SWAP_LOG_DEL) {
-           if ((e = storeGet(s.key)) != NULL)
-               storeReleaseRequest(e);
+           if ((e = storeGet(s.key)) != NULL) {
+               /*
+                * Make sure we don't unlink the file, it might be
+                * in use by a subsequent entry.  Also note that
+                * we don't have to subtract from store_swap_size
+                * because adding to store_swap_size happens in
+                * the cleanup procedure.
+                */
+               storeExpireNow(e);
+               storeSetPrivateKey(e);
+               EBIT_SET(e->flag, RELEASE_REQUEST);
+               storeDirMapBitReset(e->swap_file_number);
+               e->swap_file_number = -1;
+               RebuildState.objcount--;
+               RebuildState.cancelcount++;
+           }
            continue;
        } else {
            x = log(++RebuildState.bad_log_op) / log(10.0);
@@ -496,7 +511,7 @@ storeCleanup(void *datanotused)
        e = (StoreEntry *) link_ptr;
        if (EBIT_TEST(e->flag, ENTRY_VALIDATED))
            continue;
-       if (EBIT_TEST(e->flag, RELEASE_REQUEST))
+       if (e->swap_file_number < 0)
            continue;
        EBIT_SET(e->flag, ENTRY_VALIDATED);
        /* Only set the file bit if we know its a valid entry */
@@ -604,6 +619,7 @@ storeRebuildComplete(void)
     debug(20, 1) ("  %7d With invalid flags.\n", RebuildState.badflags);
     debug(20, 1) ("  %7d Objects loaded.\n", RebuildState.objcount);
     debug(20, 1) ("  %7d Objects expired.\n", RebuildState.expcount);
+    debug(20, 1) ("  %7d Objects cancelled.\n", RebuildState.cancelcount);
     debug(20, 1) ("  %7d Duplicate URLs purged.\n", RebuildState.dupcount);
     debug(20, 1) ("  %7d Swapfile clashes avoided.\n", RebuildState.clashcount);
     debug(20, 1) ("  Took %d seconds (%6.1lf objects/sec).\n",