/*
- * $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
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();
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");
/*
- * $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
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
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 *);