From: wessels <> Date: Fri, 17 Apr 1998 03:51:54 +0000 (+0000) Subject: need to copy old filemap to new filemap during reconfigure X-Git-Tag: SQUID_3_0_PRE1~3493 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81db2a9292784423c41e82c1c0b10c50ce31d5f9;p=thirdparty%2Fsquid.git need to copy old filemap to new filemap during reconfigure --- diff --git a/src/cache_cf.cc b/src/cache_cf.cc index a97cd39e41..feb64f573c 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -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"); diff --git a/src/filemap.cc b/src/filemap.cc index 9ecd15bb8b..e507caf3c1 100644 --- a/src/filemap.cc +++ b/src/filemap.cc @@ -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 diff --git a/src/protos.h b/src/protos.h index ad34f47720..081921bbda 100644 --- a/src/protos.h +++ b/src/protos.h @@ -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 *);