static void free_access_log(CustomLog ** definitions);
static bool setLogformat(CustomLog *cl, const char *name, const bool dieWhenMissing);
-static void update_maxobjsize(void);
static void configDoConfigure(void);
static void parse_refreshpattern(RefreshPattern **);
static uint64_t parseTimeUnits(const char *unit, bool allowMsec);
LegacyParser.destruct();
}
-static void
-update_maxobjsize(void)
-{
- int64_t ms = -1;
-
- // determine the maximum size object that can be stored to disk
- for (int i = 0; i < Config.cacheSwap.n_configured; ++i) {
- assert (Config.cacheSwap.swapDirs[i].getRaw());
-
- const int64_t storeMax = dynamic_cast<SwapDir *>(Config.cacheSwap.swapDirs[i].getRaw())->maxObjectSize();
- if (ms < storeMax)
- ms = storeMax;
- }
-
- // Ensure that we do not discard objects which could be stored only in memory.
- // It is governed by maximum_object_size_in_memory (for now)
- // TODO: update this to check each in-memory location (SMP and local memory limits differ)
- if (ms < static_cast<int64_t>(Config.Store.maxInMemObjSize))
- ms = Config.Store.maxInMemObjSize;
-
- store_maxobjsize = ms;
-}
-
static void
SetConfigFilename(char const *file_name, bool is_pipe)
{
}
sd->reconfigure();
-
- update_maxobjsize();
-
return;
}
}
sd->parse(swap->n_configured, path_str);
++swap->n_configured;
-
- /* Update the max object size */
- update_maxobjsize();
}
static const char *
extern int store_swap_low; /* 0 */
extern int store_swap_high; /* 0 */
extern size_t store_pages_max; /* 0 */
-extern int64_t store_maxobjsize; /* -1 */
+extern int64_t store_maxobjsize; /* 0 */
extern hash_table *proxy_auth_username_cache; /* NULL */
extern int incoming_sockets_accepted;
#if _SQUID_WINDOWS_
storeRegisterWithCacheManager();
}
+/// computes maximum size of a cachable object
+/// larger objects are rejected by all (disk and memory) cache stores
+static int64_t
+storeCalcMaxObjSize()
+{
+ int64_t ms = 0; // nothing can be cached without at least one store consent
+
+ // global maximum is at least the disk store maximum
+ for (int i = 0; i < Config.cacheSwap.n_configured; ++i) {
+ assert (Config.cacheSwap.swapDirs[i].getRaw());
+ const int64_t storeMax = dynamic_cast<SwapDir *>(Config.cacheSwap.swapDirs[i].getRaw())->maxObjectSize();
+ if (ms < storeMax)
+ ms = storeMax;
+ }
+
+ // global maximum is at least the memory store maximum
+ // TODO: move this into a memory cache class when we have one
+ const int64_t memMax = static_cast<int64_t>(min(Config.Store.maxInMemObjSize, Config.memMaxSize));
+ if (ms < memMax)
+ ms = memMax;
+
+ return ms;
+}
+
void
storeConfigure(void)
{
store_swap_low = (long) (((float) Store::Root().maxSize() *
(float) Config.Swap.lowWaterMark) / (float) 100);
store_pages_max = Config.memMaxSize / sizeof(mem_node);
+
+ store_maxobjsize = storeCalcMaxObjSize();
}
bool
return false;
}
- // check cache_dir max-size limit if all cache_dirs have it
- if (store_maxobjsize >= 0) {
+ // handle store_maxobjsize limit
+ {
// TODO: add estimated store metadata size to be conservative
// use guaranteed maximum if it is known