]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
need to copy old filemap to new filemap during reconfigure
authorwessels <>
Fri, 17 Apr 1998 03:51:54 +0000 (03:51 +0000)
committerwessels <>
Fri, 17 Apr 1998 03:51:54 +0000 (03:51 +0000)
src/cache_cf.cc
src/filemap.cc
src/protos.h

index a97cd39e41bf3965640c42c8256063387c788950..feb64f573cd9ab20c519e13c7b8d54aa985adbba 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_cf.cc,v 1.276 1998/04/16 18:14:54 wessels Exp $
+ * $Id: cache_cf.cc,v 1.277 1998/04/16 21:51:54 wessels Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -194,6 +194,8 @@ configDoConfigure(void)
     LOCAL_ARRAY(char, buf, BUFSIZ);
     int i;
     SwapDir *SD;
+    fileMap *fm;
+    int n;
     memset(&Config2, '\0', sizeof(SquidConfig2));
     /* init memory as early as possible */
     memConfigure();
@@ -205,7 +207,18 @@ configDoConfigure(void)
     for (i = 0; i < Config.cacheSwap.n_configured; i++) {
         SD = &Config.cacheSwap.swapDirs[i];;
        Config.Swap.maxSize += SD->max_size;
-        SD->map = file_map_create(2 * SD->max_size / Config.Store.avgObjectSize);
+       n = 2 * SD->max_size / Config.Store.avgObjectSize;
+       if (NULL == SD->map) {
+           /* first time */
+           SD->map = file_map_create(n);
+       } else if (n > SD->map->max_n_files) {
+           /* it grew, need to expand */
+           fm = file_map_create(n);
+            filemapCopy(SD->map, fm);
+           filemapFreeMemory(SD->map);
+           SD->map = fm;
+       }
+       /* else it shrunk, and we leave the old one in place */
     }
     if (Config.Swap.maxSize < (Config.Mem.maxSize >> 10))
        fatal("cache_swap is lower than cache_mem");
index 9ecd15bb8bf3761ec9026ca7a7858a1314b0ab3e..e507caf3c1ef50c07d00726371c7f28e6e8734bd 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: filemap.cc,v 1.24 1998/03/06 22:19:33 wessels Exp $
+ * $Id: filemap.cc,v 1.25 1998/04/16 21:51:55 wessels Exp $
  *
  * DEBUG: section 8     Swap File Bitmap
  * AUTHOR: Harvest Derived
@@ -203,6 +203,15 @@ filemapFreeMemory(fileMap * fm)
     safe_free(fm);
 }
 
+void
+filemapCopy(fileMap * old, fileMap * new)
+{
+    assert(old->max_n_files <= new->max_n_files);
+    assert(0 == new->n_files_in_map);
+    xmemcpy(new->file_map, old->file_map, old->nwords * sizeof(unsigned long));
+    new->n_files_in_map = old->n_files_in_map;
+}
+
 #ifdef TEST
 
 #define TEST_SIZE 1<<16
index ad34f477200a567cc5e42da6dd0529272d25320e..081921bbda4854dff5a93ddb4b6179d018991fc7 100644 (file)
@@ -182,6 +182,7 @@ extern int file_map_bit_set(fileMap *, int);
 extern int file_map_bit_test(fileMap *, int);
 extern void file_map_bit_reset(fileMap *, int);
 extern void filemapFreeMemory(fileMap *);
+extern void filemapCopy(fileMap *old, fileMap *new);
 
 
 extern void fqdncache_nbgethostbyaddr(struct in_addr, FQDNH *, void *);