]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Check the limit early in hope to catch cases when it becomes zero.
authorAlex Rousskov <rousskov@measurement-factory.com>
Wed, 13 Apr 2011 20:11:39 +0000 (14:11 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Wed, 13 Apr 2011 20:11:39 +0000 (14:11 -0600)
We could support maps with zero limits, but they should not be needed for now.

src/ipc/StoreMap.cc

index de92915bbbf79043daa03c6ba079cd6ce130f1e1..705f17185553eee1d9a13c9a2bee0e34a0b59329 100644 (file)
@@ -13,6 +13,7 @@ Ipc::StoreMap::StoreMap(const char *const aPath, const int limit,
     size_t sharedSizeExtra):
     cleaner(NULL), path(aPath), shm(aPath), shared(NULL)
 {
+    assert(limit > 0); // we should not be created otherwise
     const size_t mySharedSize = Shared::MemSize(limit);
     shm.create(mySharedSize + sharedSizeExtra);
     shared = new (shm.reserve(mySharedSize)) Shared(limit);
@@ -25,7 +26,8 @@ Ipc::StoreMap::StoreMap(const char *const aPath):
     shm.open();
     assert(shm.mem());
     shared = reinterpret_cast<Shared *>(shm.mem());
-    // check that nobody used our segment chunk and that shared->limit is sane
+    assert(shared->limit > 0); // we should not be created otherwise
+    // now that the limit is checked, check that nobody used our segment chunk
     assert(shared == reinterpret_cast<Shared *>(shm.reserve(Shared::MemSize(shared->limit))));
     debugs(54, 5, HERE << "attached map [" << path << "] created: " << shared->limit);
 }