Moving the cache_peer pool to the peer init area has brought to light
the problem of this pool init function not being safe for repeated
calls. (bug 3245)
We had some discussion when the opposite of this came up about strings.
Since we have not really settled on whether to make MemPools an
on-first-demand system I think its time to make some kind of TODO plan now.
Do we want to eventually make memory initialization happen on first use?
In which case I commit this patch now as one small step towards that.
Or do we want to set an absolute init order and fail loudly if
components are initialized in the wrong order?
In which case I revert the peerSelectInit() changes.
Amos
--
Please be using
Current Stable Squid 2.7.STABLE9 or 3.1.12
Beta testers wanted for 3.2.0.9 and 3.1.12.3
=== modified file 'src/mem.cc'
--- src/mem.cc 2011-04-07 00:18:17 +0000
+++ src/mem.cc 2011-06-21 12:31:35 +0000
@@ -180,14 +180,20 @@
*/
/*
- * we have a limit on _total_ amount of idle memory so we ignore
- * max_pages for now
+ * we have a limit on _total_ amount of idle memory so we ignore max_pages for now.
+ * Will ignore repeated calls for the same pool type.
+ *
+ * Relies on Mem::Init() having been called beforehand.
*/
void
memDataInit(mem_type type, const char *name, size_t size, int max_pages_notused, bool zeroOnPush)
{
+ assert(MemIsInitialized);
assert(name && size);
- assert(MemPools[type] == NULL);
+
+ if (MemPools[type] != NULL)
+ return;
+
MemPools[type] = memPoolCreate(name, size);
MemPools[type]->zeroOnPush(zeroOnPush);
}