patch: -S auto-fixing

From: Robert Collins <robert.collins@dont-contact.us>
Date: Tue, 17 Oct 2000 18:11:51 +1100

Hi
the inserted patch changes store_rebuild to unlink entries that are faulty
during a -S check, and report the errors rather than asserting.
I tested it out by removing fiels, I haven't verified against incorrect
length (should work though).

I also haven't tested it in a big chache where requests are coming in during
the process. It should work though as the faulty entries are never marked as
validated.

Rob

--- ../../squid-orig/src/store_rebuild.c Thu May 4 05:18:13 2000
+++ store_rebuild.c Tue Oct 17 17:51:31 2000
@@ -64,8 +64,9 @@
            debug(20, 1) (" store_swap_size = %dk\n", store_swap_size);
            store_dirs_rebuilding--;
            assert(0 == store_dirs_rebuilding);
- if (opt_store_doublecheck)
- assert(store_errors == 0);
+ if (opt_store_doublecheck){
+ debug(20, 1) (" Found %d errors during
Validation\n",store_errors);
+ }
            if (store_digest)
                storeDigestNoteStoreReady();
            return;
@@ -82,17 +83,39 @@
             */
            if (e->swap_filen < 0)
                continue;
- if (opt_store_doublecheck)
- if (storeCleanupDoubleCheck(e))
+ /*
+ * the doublecheck may need to have the file removed from the
store.
+ * this is ugly
+ */
+ if (opt_store_doublecheck){
+ if (storeCleanupDoubleCheck(e)){
+ /*
+ * remove the problematic entry.
+ */
+ storeUnlink(e);
                    store_errors++;
- EBIT_SET(e->flags, ENTRY_VALIDATED);
- /*
- * Only set the file bit if we know its a valid entry
- * otherwise, set it in the validation procedure
- */
- storeDirUpdateSwapSize(&Config.cacheSwap.swapDirs[e->swap_dirn],
e->swap_file_sz, 1);
- if ((++validnum & 0x3FFFF) == 0)
- debug(20, 1) (" %7d Entries Validated so far.\n",
validnum);
+ }
+ else{
+ EBIT_SET(e->flags, ENTRY_VALIDATED);
+ /*
+ * Only set the file bit if we know its a valid entry
+ * otherwise, set it in the validation procedure
+ */
+
storeDirUpdateSwapSize(&Config.cacheSwap.swapDirs[e->swap_dirn],
e->swap_file_sz, 1);
+ if ((++validnum & 0x3FFFF) == 0)
+ debug(20, 1) (" %7d Entries Validated so far.\n",
validnum);
+ }
+ }
+ else{
+ EBIT_SET(e->flags, ENTRY_VALIDATED);
+ /*
+ * Only set the file bit if we know its a valid entry
+ * otherwise, set it in the validation procedure
+ */
+
storeDirUpdateSwapSize(&Config.cacheSwap.swapDirs[e->swap_dirn],
e->swap_file_sz, 1);
+ if ((++validnum & 0x3FFFF) == 0)
+ debug(20, 1) (" %7d Entries Validated so far.\n",
validnum);
+ }
        }
     }
     eventAdd("storeCleanup", storeCleanup, NULL, 0.0, 1);
Received on Tue Oct 17 2000 - 01:07:59 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:12:43 MST