]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
- Take Stewarts MONOTONIC_STORE patch, remove the #else code
authorwessels <>
Thu, 5 Feb 1998 06:41:00 +0000 (06:41 +0000)
committerwessels <>
Thu, 5 Feb 1998 06:41:00 +0000 (06:41 +0000)
- create storeUnlinkFileno() to consolidate some USE_ASYNC_IO #ifdefs
- added storeKeyInit()
- added storeKeyNull()
- Fixed storeRebuildFromDirectory() FUM bug.
- Removed unused fileno stack stuff.  replaced by MONOTONIC_STORE changes
- Fixed storeClientReadBody() and storeClientReadHeaders() to call
  httpParseReplyHeaders()
- Modified storeDirOpenTmpSwapLog() to return whether or not the
  existing swap.state file has any entries, so we know to use
  storeRebuildFromDirectory.

src/store.cc
src/store_client.cc
src/store_dir.cc
src/store_key_md5.cc
src/store_log.cc
src/store_rebuild.cc
src/store_swapin.cc
src/store_swapmeta.cc
src/store_swapout.cc

index 21308994692305bbcdb766c3fa247ecb129c4c58..d63e0418db5c106b60673b59f52cef9f204f73e3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.375 1998/02/04 00:18:04 wessels Exp $
+ * $Id: store.cc,v 1.376 1998/02/04 23:41:00 wessels Exp $
  *
  * DEBUG: section 20    Storeage Manager
  * AUTHOR: Harvest Derived
@@ -708,7 +708,10 @@ storeRelease(StoreEntry * e)
        return;
     }
 #if USE_ASYNC_IO
-    aioCancel(-1, e);          /* Make sure all forgotten async ops are cancelled */
+    /*
+     * Make sure all forgotten async ops are cancelled
+     */
+    aioCancel(-1, e);
 #else
     if (store_rebuilding) {
        debug(20, 2) ("storeRelease: Delaying release until store is rebuilt: '%s'\n",
@@ -722,15 +725,7 @@ storeRelease(StoreEntry * e)
 #endif
     storeLog(STORE_LOG_RELEASE, e);
     if (e->swap_file_number > -1) {
-#if MONOTONIC_STORE
-#if USE_ASYNC_IO
-       safeunlink(storeSwapFullPath(e->swap_file_number, NULL), 1);
-#else
-       unlinkdUnlink(storeSwapFullPath(e->swap_file_number, NULL));
-#endif
-#else
-       storePutUnusedFileno(e);
-#endif
+       storeUnlinkFileno(e->swap_file_number);
        if (e->swap_status == SWAPOUT_DONE)
            storeDirUpdateSwapSize(e->swap_file_number, e->object_len, -1);
        storeDirSwapLog(e, SWAP_LOG_DEL);
@@ -828,6 +823,7 @@ storeInitHashValues(void)
 void
 storeInit(void)
 {
+    storeKeyInit();
     storeInitHashValues();
     store_table = hash_create(storeKeyHashCmp,
        store_hash_buckets, storeKeyHashHash);
@@ -988,50 +984,6 @@ storeTimestampsSet(StoreEntry * entry)
     entry->timestamp = served_date;
 }
 
-#define FILENO_STACK_SIZE 128
-static int fileno_stack[FILENO_STACK_SIZE];
-
-#if !MONOTONIC_STORE
-int
-storeGetUnusedFileno(void)
-{
-    int fn;
-    if (fileno_stack_count < 1)
-       return -1;
-    fn = fileno_stack[--fileno_stack_count];
-    assert(!storeDirMapBitTest(fn));
-    storeDirMapBitSet(fn);
-    return fn;
-}
-
-void
-storePutUnusedFileno(StoreEntry * e)
-{
-    assert(storeDirMapBitTest(e->swap_file_number));
-    storeDirMapBitReset(e->swap_file_number);
-    /* If we're still rebuilding the swap state, then we need to avoid the */
-    /* race condition where a new object gets pulled in, it expires, gets */
-    /* its swapfileno added to the stack, and then that swapfileno gets */
-    /* claimed by the rebuild. Must still remove the file though in any */
-    /* event to avoid serving up the wrong data.  This will leave us with */
-    /* a URL pointing to no file at all, but that's okay since it'll fail */
-    /* and get removed later anyway. */
-    if (store_rebuilding) {
-       if (EBIT_TEST(e->flag, ENTRY_VALIDATED))
-           safeunlink(storeSwapFullPath(e->swap_file_number, NULL), 1);
-       return;
-    }
-    if (fileno_stack_count < FILENO_STACK_SIZE)
-       fileno_stack[fileno_stack_count++] = e->swap_file_number;
-    else
-#if USE_ASYNC_IO
-       safeunlink(storeSwapFullPath(e->swap_file_number, NULL), 1);
-#else
-       unlinkdUnlink(storeSwapFullPath(e->swap_file_number, NULL));
-#endif
-}
-#endif
-
 void
 storeRegisterAbort(StoreEntry * e, STABH * cb, void *data)
 {
@@ -1165,3 +1117,13 @@ storeBufferFlush(StoreEntry * e)
     EBIT_CLR(e->flag, DELAY_SENDING);
     InvokeHandlers(e);
 }
+
+void
+storeUnlinkFileno(int fileno)
+{
+#if USE_ASYNC_IO
+    safeunlink(storeSwapFullPath(fileno, NULL), 1);
+#else
+    unlinkdUnlink(storeSwapFullPath(fileno, NULL));
+#endif
+}
index 715e1bec925e5e9eb349f7bf5d2a5fc5555cad5e..2295c8d9721dbc77f1a8433756b3c7d082b6598f 100644 (file)
@@ -216,11 +216,14 @@ static void
 storeClientReadBody(int fd, const char *buf, int len, int flagnotused, void *data)
 {
     store_client *sc = data;
+    MemObject *mem = sc->mem;
     STCB *callback = sc->callback;
     assert(sc->disk_op_in_progress != 0);
     sc->disk_op_in_progress = 0;
     assert(sc->callback != NULL);
     debug(20, 3) ("storeClientReadBody: FD %d, len %d\n", fd, len);
+    if (sc->copy_offset == 0 && len > 0 && mem->reply->code == 0)
+       httpParseReplyHeaders(sc->copy_buf, mem->reply);
     sc->callback = NULL;
     callback(sc->callback_data, sc->copy_buf, len);
 }
@@ -243,18 +246,18 @@ storeClientReadHeader(int fd, const char *buf, int len, int flagnotused, void *d
     assert(sc->callback != NULL);
     debug(20, 3) ("storeClientReadHeader: FD %d, len %d\n", fd, len);
     if (len < 0) {
-        debug(20, 3) ("storeClientReadHeader: FD %d: %s\n", fd, xstrerror());
+       debug(20, 3) ("storeClientReadHeader: FD %d: %s\n", fd, xstrerror());
        memFree(MEM_DISK_BUF, (void *) buf);
-        sc->callback = NULL;
-        callback(sc->callback_data, sc->copy_buf, len);
+       sc->callback = NULL;
+       callback(sc->callback_data, sc->copy_buf, len);
        return;
     }
     tlv_list = storeSwapMetaUnpack(buf, &swap_hdr_sz);
     if (tlv_list == NULL) {
-        debug(20, 1) ("storeClientReadHeader: failed to unpack meta data\n");
+       debug(20, 1) ("storeClientReadHeader: failed to unpack meta data\n");
        memFree(MEM_DISK_BUF, (void *) buf);
-        sc->callback = NULL;
-        callback(sc->callback_data, sc->copy_buf, -1);
+       sc->callback = NULL;
+       callback(sc->callback_data, sc->copy_buf, -1);
        return;
     }
     /*
@@ -269,15 +272,17 @@ storeClientReadHeader(int fd, const char *buf, int len, int flagnotused, void *d
     body_sz = len - swap_hdr_sz;
     if (sc->copy_offset < body_sz) {
        /*
-         * we have (part of )what they want
+        * we have (part of) what they want
         */
        copy_sz = XMIN(sc->copy_size, body_sz);
-       debug(20,3)("storeClientReadHeader: copying %d bytes of body\n",
-               copy_sz);
-       xmemcpy(sc->copy_buf, buf+swap_hdr_sz, copy_sz);
+       debug(20, 3) ("storeClientReadHeader: copying %d bytes of body\n",
+           copy_sz);
+       xmemcpy(sc->copy_buf, buf + swap_hdr_sz, copy_sz);
        memFree(MEM_DISK_BUF, (void *) buf);
+       if (sc->copy_offset == 0 && len > 0 && mem->reply->code == 0)
+           httpParseReplyHeaders(sc->copy_buf, mem->reply);
        sc->callback = NULL;
-        callback(sc->callback_data, sc->copy_buf, copy_sz);
+       callback(sc->callback_data, sc->copy_buf, copy_sz);
        return;
     }
     /*
index c37fa663049ec500b696ab0406a6d48b45f560c2..3ac9026553443fae65e867de642b93fdc37926bc 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir.cc,v 1.45 1998/02/04 07:01:21 wessels Exp $
+ * $Id: store_dir.cc,v 1.46 1998/02/04 23:41:02 wessels Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -52,19 +52,11 @@ storeSwapFullPath(int fn, char *fullpath)
     if (!fullpath)
        fullpath = fullfilename;
     fullpath[0] = '\0';
-#if MONOTONIC_STORE
     snprintf(fullpath, SQUID_MAXPATHLEN, "%s/%02X/%02X/%08X",
        Config.cacheSwap.swapDirs[dirn].path,
        ((filn / Config.cacheSwap.swapDirs[dirn].l2) / Config.cacheSwap.swapDirs[dirn].l2) % Config.cacheSwap.swapDirs[dirn].l1,
        (filn / Config.cacheSwap.swapDirs[dirn].l2) % Config.cacheSwap.swapDirs[dirn].l2,
        filn);
-#else
-    snprintf(fullpath, SQUID_MAXPATHLEN, "%s/%02X/%02X/%08X",
-       Config.cacheSwap.swapDirs[dirn].path,
-       filn % Config.cacheSwap.swapDirs[dirn].l1,
-       filn / Config.cacheSwap.swapDirs[dirn].l1 % Config.cacheSwap.swapDirs[dirn].l2,
-       filn);
-#endif
     return fullpath;
 }
 
@@ -91,17 +83,10 @@ storeSwapSubSubDir(int fn, char *fullpath)
     if (!fullpath)
        fullpath = fullfilename;
     fullpath[0] = '\0';
-#if MONOTONIC_STORE
     snprintf(fullpath, SQUID_MAXPATHLEN, "%s/%02X/%02X",
        Config.cacheSwap.swapDirs[dirn].path,
        ((filn / Config.cacheSwap.swapDirs[dirn].l2) / Config.cacheSwap.swapDirs[dirn].l2) % Config.cacheSwap.swapDirs[dirn].l1,
        (filn / Config.cacheSwap.swapDirs[dirn].l2) % Config.cacheSwap.swapDirs[dirn].l2);
-#else
-    snprintf(fullpath, SQUID_MAXPATHLEN, "%s/%02X/%02X",
-       Config.cacheSwap.swapDirs[dirn].path,
-       filn % Config.cacheSwap.swapDirs[dirn].l1,
-       filn / Config.cacheSwap.swapDirs[dirn].l1 % Config.cacheSwap.swapDirs[dirn].l2);
-#endif
     return fullpath;
 }
 
@@ -241,9 +226,6 @@ storeDirMapBitSet(int fn)
     int dirn = fn >> SWAP_DIR_SHIFT;
     int filn = fn & SWAP_FILE_MASK;
     file_map_bit_set(Config.cacheSwap.swapDirs[dirn].map, filn);
-#if !MONOTONIC_STORE
-    Config.cacheSwap.swapDirs[dirn].suggest++;
-#endif
 }
 
 void
@@ -252,10 +234,6 @@ storeDirMapBitReset(int fn)
     int dirn = fn >> SWAP_DIR_SHIFT;
     int filn = fn & SWAP_FILE_MASK;
     file_map_bit_reset(Config.cacheSwap.swapDirs[dirn].map, filn);
-#if !MONOTONIC_STORE
-    if (fn < Config.cacheSwap.swapDirs[dirn].suggest)
-       Config.cacheSwap.swapDirs[dirn].suggest = fn;
-#endif
 }
 
 int
@@ -264,9 +242,7 @@ storeDirMapAllocate(void)
     int dirn = storeMostFreeSwapDir();
     SwapDir *SD = &Config.cacheSwap.swapDirs[dirn];
     int filn = file_map_allocate(SD->map, SD->suggest);
-#if MONOTONIC_STORE
     SD->suggest = filn + 1;
-#endif
     return (dirn << SWAP_DIR_SHIFT) | (filn & SWAP_FILE_MASK);
 }
 
@@ -378,7 +354,7 @@ storeDirCloseSwapLogs(void)
 }
 
 FILE *
-storeDirOpenTmpSwapLog(int dirn, int *clean_flag)
+storeDirOpenTmpSwapLog(int dirn, int *clean_flag, int *zero_flag)
 {
     char *swaplog_path = xstrdup(storeDirSwapLogFile(dirn, NULL));
     char *clean_path = xstrdup(storeDirSwapLogFile(dirn, ".last-clean"));
@@ -395,6 +371,7 @@ storeDirOpenTmpSwapLog(int dirn, int *clean_flag)
        safe_free(new_path);
        return NULL;
     }
+    *zero_flag = log_sb.st_size == 0 ? 1 : 0;
     /* close the existing write-only FD */
     if (SD->swaplog_fd >= 0)
        file_close(SD->swaplog_fd);
@@ -562,24 +539,24 @@ storeDirWriteCleanLogs(int reopen)
        assert(dirn < Config.cacheSwap.n_configured);
        if (fd[dirn] < 0)
            continue;
-        s = (void *) outbuf[dirn] + outbufoffset[dirn];
+       s = (void *) outbuf[dirn] + outbufoffset[dirn];
        outbufoffset[dirn] += sizeof(storeSwapData);
-        memset(s, '\0', sizeof(storeSwapData));
-        s->op = (char) SWAP_LOG_ADD;
-        s->swap_file_number = e->swap_file_number;
-        s->timestamp = e->timestamp;
-        s->lastref = e->lastref;
-        s->expires = e->expires;
-        s->lastmod = e->lastmod;
-        s->object_len = e->object_len;
-        s->refcount = e->refcount;
-        s->flags = e->flag;
-        xmemcpy(s->key, e->key, MD5_DIGEST_CHARS);
+       memset(s, '\0', sizeof(storeSwapData));
+       s->op = (char) SWAP_LOG_ADD;
+       s->swap_file_number = e->swap_file_number;
+       s->timestamp = e->timestamp;
+       s->lastref = e->lastref;
+       s->expires = e->expires;
+       s->lastmod = e->lastmod;
+       s->object_len = e->object_len;
+       s->refcount = e->refcount;
+       s->flags = e->flag;
+       xmemcpy(s->key, e->key, MD5_DIGEST_CHARS);
        /* buffered write */
        if (outbufoffset[dirn] + sizeof(storeSwapData) > CLEAN_BUF_SZ) {
            if (write(fd[dirn], outbuf[dirn], outbufoffset[dirn]) < 0) {
                debug(50, 0) ("storeDirWriteCleanLogs: %s: %s\n",
-                       new[dirn], xstrerror());
+                   new[dirn], xstrerror());
                debug(20, 0) ("storeDirWriteCleanLogs: Current swap logfile not replaced.\n");
                file_close(fd[dirn]);
                fd[dirn] = -1;
index 28a7739dde03aaa0655f0ef2b5be7d674a9633ab..0daed041e65879798924fc50a92a8b9e8cbc667a 100644 (file)
@@ -1,5 +1,7 @@
 #include "squid.h"
 
+static cache_key null_key[MD5_DIGEST_CHARS];
+
 const char *
 storeKeyText(const unsigned char *key)
 {
@@ -118,3 +120,18 @@ storeKeyHashBuckets(int nobj)
        return 0x8000;
     return 0x10000;
 }
+
+int
+storeKeyNull(const cache_key * key)
+{
+    if (memcmp(key, null_key, MD5_DIGEST_CHARS) == 0)
+       return 1;
+    else
+       return 0;
+}
+
+void
+storeKeyInit(void)
+{
+    memset(null_key, '\0', MD5_DIGEST_CHARS);
+}
index a7756a9b0b6ed302a57ec97e62f3fc1ce85c443d..f6bab8673fcfb1d18793c92fb867c219102b3e93 100644 (file)
@@ -1,3 +1,4 @@
+
 #include "squid.h"
 
 static char *storeLogTags[] =
@@ -109,10 +110,10 @@ storeLogOpen(void)
        storelog_fd = -1;
     else
        storelog_fd = file_open(Config.Log.store,
-               O_WRONLY | O_CREAT,
-               NULL,
-               NULL,
-               NULL);
+           O_WRONLY | O_CREAT,
+           NULL,
+           NULL,
+           NULL);
     if (storelog_fd < 0)
-        debug(20, 1) ("Store logging disabled\n");
+       debug(20, 1) ("Store logging disabled\n");
 }
index 19dc78a691c97d9c8f718c2ed91f76bc60882a49..1f2e465c51bdf712ea10b74e6de3e1d009eca965 100644 (file)
@@ -29,12 +29,13 @@ struct storeRebuildState {
     int objcount;              /* # objects successfully reloaded */
     int expcount;              /* # objects expired */
     int linecount;             /* # lines parsed from cache logfile */
+    int statcount;             /* # entries from directory walking */
     int clashcount;            /* # swapfile clashes avoided */
-    int cancelcount;           /* # objects cancelled */
     int dupcount;              /* # duplicates purged */
     int invalid;               /* # bad lines */
     int badflags;              /* # bad e->flags */
     int need_to_validate;
+    int zero_object_len;
     time_t start;
     time_t stop;
 } RebuildState;
@@ -58,15 +59,16 @@ storeRebuildFromDirectory(rebuild_dir * d)
     LOCAL_ARRAY(char, hdr_buf, DISK_PAGE_SIZE);
     StoreEntry *e = NULL;
     StoreEntry tmpe;
+    cache_key key[MD5_DIGEST_CHARS];
     int sfileno = 0;
     int count;
     int size;
     struct stat fst;
-    static int filecount;
     int hdr_len;
     int fd = -1;
     tlv *tlv_list;
     tlv *t;
+    double x;
     assert(d != NULL);
     debug(20, 3) ("storeRebuildFromDirectory: DIR #%s\n", d->dirn);
     for (count = 0; count < d->speed; count++) {
@@ -88,8 +90,9 @@ storeRebuildFromDirectory(rebuild_dir * d)
            fd = -1;
            continue;
        }
-       if ((++filecount & 0x3FFF) == 0)
-           debug(20, 1) ("  %7d files processed so far.\n", RebuildState.linecount);
+       if ((++RebuildState.statcount & 0x3FFF) == 0)
+           debug(20, 1) ("  %7d files opened so far.\n",
+               RebuildState.statcount);
        debug(20, 9) ("file_in: fd=%d %08x\n", fd, sfileno);
        if (read(fd, hdr_buf, DISK_PAGE_SIZE) < 0) {
            debug(20, 1) ("storeRebuildFromDirectory: read(FD %d): %s\n",
@@ -104,18 +107,20 @@ storeRebuildFromDirectory(rebuild_dir * d)
        tlv_list = storeSwapMetaUnpack(hdr_buf, &hdr_len);
        if (tlv_list == NULL) {
            debug(20, 1) ("storeRebuildFromDirectory: failed to get meta data\n");
-           safeunlink(storeSwapFullPath(sfileno, NULL), 1);
+           storeUnlinkFileno(sfileno);
            continue;
        }
-       debug(20, 1) ("storeRebuildFromDirectory: successful swap meta unpacking\n");
-       storeKeyFree(tmpe.key);
+       debug(20, 3) ("storeRebuildFromDirectory: successful swap meta unpacking\n");
+       memset(key, '\0', MD5_DIGEST_CHARS);
        memset(&tmpe, '\0', sizeof(StoreEntry));
        for (t = tlv_list; t; t = t->next) {
            switch (t->type) {
            case STORE_META_KEY:
-               tmpe.key = storeKeyDup(t->value);
+               assert(t->length == MD5_DIGEST_CHARS);
+               xmemcpy(key, t->value, MD5_DIGEST_CHARS);
                break;
            case STORE_META_STD:
+               assert(t->length == STORE_HDR_METASIZE);
                xmemcpy(&tmpe.timestamp, t->value, STORE_HDR_METASIZE);
                break;
            default:
@@ -124,29 +129,34 @@ storeRebuildFromDirectory(rebuild_dir * d)
        }
        storeSwapTLVFree(tlv_list);
        tlv_list = NULL;
-       if (tmpe.key == NULL) {
+       if (storeKeyNull(key)) {
            debug(20, 1) ("storeRebuildFromDirectory: NULL key\n");
-           safeunlink(storeSwapFullPath(sfileno, NULL), 1);
+           storeUnlinkFileno(sfileno);
            continue;
        }
+       tmpe.key = key;
        if (tmpe.object_len == 0) {
-           debug(20, 1) ("storeRebuildFromDirectory: ZERO object length\n");
-           safeunlink(storeSwapFullPath(sfileno, NULL), 1);
+           RebuildState.invalid++;
+           x = log(++RebuildState.zero_object_len) / log(10.0);
+           if (0.0 == x - (double) (int) x)
+               debug(20, 1) ("WARNING: %d swapfiles found with ZERO length\n",
+                   RebuildState.zero_object_len);
+           storeUnlinkFileno(sfileno);
            continue;
        }
        /* check sizes */
        if (hdr_len + tmpe.object_len != fst.st_size) {
            debug(20, 1) ("storeRebuildFromDirectory: SIZE MISMATCH %d+%d!=%d\n",
                hdr_len, tmpe.object_len, fst.st_size);
-           safeunlink(storeSwapFullPath(sfileno, NULL), 1);
+           storeUnlinkFileno(sfileno);
            continue;
        }
        if (EBIT_TEST(tmpe.flag, KEY_PRIVATE)) {
-           safeunlink(storeSwapFullPath(sfileno, NULL), 1);
+           storeUnlinkFileno(sfileno);
            RebuildState.badflags++;
            continue;
        }
-       if ((e = storeGet(tmpe.key)) != NULL) {
+       if ((e = storeGet(key)) != NULL) {
            /* URL already exists, this swapfile not being used */
            /* junk old, load new */
            storeRelease(e);    /* release old entry */
@@ -154,7 +164,7 @@ storeRebuildFromDirectory(rebuild_dir * d)
        }
        RebuildState.objcount++;
        storeEntryDump(&tmpe, 5);
-       e = storeAddDiskRestore(tmpe.key,
+       e = storeAddDiskRestore(key,
            sfileno,
            (int) tmpe.object_len,
            tmpe.expires,
@@ -200,7 +210,8 @@ storeRebuildFromSwapLog(rebuild_dir * d)
            continue;
        }
        if ((++RebuildState.linecount & 0x3FFF) == 0)
-           debug(20, 1) ("  %7d Entries read so far.\n", RebuildState.linecount);
+           debug(20, 1) ("  %7d Entries read so far.\n",
+               RebuildState.linecount);
        if (!storeDirValidFileno(s.swap_file_number)) {
            RebuildState.invalid++;
            continue;
@@ -581,11 +592,12 @@ storeRebuildComplete(void)
     debug(20, 1) ("Finished rebuilding storage disk.\n");
     debug(20, 1) ("  %7d Entries read from previous logfile.\n",
        RebuildState.linecount);
+    debug(20, 1) ("  %7d Entries scanned from swap files.\n",
+       RebuildState.statcount);
     debug(20, 1) ("  %7d Invalid entries.\n", RebuildState.invalid);
     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",
@@ -599,6 +611,7 @@ storeRebuildStart(void)
 {
     rebuild_dir *d;
     int clean = 0;
+    int zero = 0;
     FILE *fp;
     int i;
     memset(&RebuildState, '\0', sizeof(RebuildState));
@@ -613,8 +626,8 @@ storeRebuildStart(void)
         * use storeRebuildFromDirectory() to open up each file
         * and suck in the meta data.
         */
-       fp = storeDirOpenTmpSwapLog(i, &clean);
-       if (fp == NULL) {
+       fp = storeDirOpenTmpSwapLog(i, &clean, &zero);
+       if (fp == NULL || zero) {
            d->rebuild_func = storeRebuildFromDirectory;
        } else {
            d->rebuild_func = storeRebuildFromSwapLog;
index dbaa47fa44045dc29b4eb89a10f7b609a5570354..d73ce723d20b5596fc8c8f30c344b8e7b4016e2c 100644 (file)
@@ -108,4 +108,3 @@ storeSwapInFileOpened(void *data, int fd, int errcode)
     xfree(ctrlp->path);
     xfree(ctrlp);
 }
-
index 39fe0fb3cfb2fc8684469567c66f3b5aa56b7869..9ddcfe1468c5c72af08aa9dd46dd9a746fd59f4c 100644 (file)
@@ -1,3 +1,4 @@
+
 #include "squid.h"
 
 static tlv **
index ea04cdf3406ddd9132b2ea7e085380ea892e9a95..e3da6152ee635672a732a6a916407b1516f4cd82 100644 (file)
@@ -15,10 +15,7 @@ storeSwapOutStart(StoreEntry * e)
     swapout_ctrl_t *ctrlp;
     LOCAL_ARRAY(char, swapfilename, SQUID_MAXPATHLEN);
     storeLockObject(e);
-#if !MONOTONIC_STORE
-    if ((e->swap_file_number = storeGetUnusedFileno()) < 0)
-#endif
-       e->swap_file_number = storeDirMapAllocate();
+    e->swap_file_number = storeDirMapAllocate();
     storeSwapFullPath(e->swap_file_number, swapfilename);
     ctrlp = xmalloc(sizeof(swapout_ctrl_t));
     ctrlp->swapfilename = xstrdup(swapfilename);
@@ -42,15 +39,7 @@ storeSwapOutHandle(int fdnotused, int flag, size_t len, void *data)
            flag);
        e->swap_status = SWAPOUT_NONE;
        if (e->swap_file_number > -1) {
-#if MONOTONIC_STORE
-#if USE_ASYNC_IO
-           safeunlink(storeSwapFullPath(e->swap_file_number, NULL), 1);
-#else
-           unlinkdUnlink(storeSwapFullPath(e->swap_file_number, NULL));
-#endif
-#else
-           storePutUnusedFileno(e);
-#endif
+           storeUnlinkFileno(e->swap_file_number);
            e->swap_file_number = -1;
        }
        if (flag == DISK_NO_SPACE_LEFT) {