]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Polished calculation of the number of needed memory pages for one Store write.
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 3 Nov 2011 21:09:04 +0000 (15:09 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Thu, 3 Nov 2011 21:09:04 +0000 (15:09 -0600)
The old code was overestimating the number of memory pages required when we
needed to write exactly n*SM_PAGE_SIZE bytes.

src/store.cc

index 7dbfc1d59e5c4e17112ace88fd3fce6ceb3b61f2..3be12fcfa4af0d0e1fa780cca7871635290d8e07 100644 (file)
@@ -1170,7 +1170,7 @@ storeGetMemSpace(int size)
 
     last_check = squid_curtime;
 
-    pages_needed = (size / SM_PAGE_SIZE) + 1;
+    pages_needed = (size + SM_PAGE_SIZE-1) / SM_PAGE_SIZE;
 
     if (mem_node::InUseCount() + pages_needed < store_pages_max) {
         PROF_stop(storeGetMemSpace);