From: wessels <> Date: Sat, 7 Feb 1998 00:47:07 +0000 (+0000) Subject: Fixed store_rebuild handling of SWAP_LOG_DEL. Don't want to call X-Git-Tag: SQUID_3_0_PRE1~4146 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6c57e2687cf83747934f4447e2b8a7b5bc4ace08;p=thirdparty%2Fsquid.git Fixed store_rebuild handling of SWAP_LOG_DEL. Don't want to call 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. --- diff --git a/src/protos.h b/src/protos.h index 0d06ad6c79..6d1039dc26 100644 --- a/src/protos.h +++ b/src/protos.h @@ -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 diff --git a/src/store.cc b/src/store.cc index d63e0418db..62ce8a6f28 100644 --- a/src/store.cc +++ b/src/store.cc @@ -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; diff --git a/src/store_dir.cc b/src/store_dir.cc index 3ac9026553..db444f47c5 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -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) diff --git a/src/store_rebuild.cc b/src/store_rebuild.cc index f8da7ab46b..f753b3557b 100644 --- a/src/store_rebuild.cc +++ b/src/store_rebuild.cc @@ -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",