From: Alex Rousskov Date: Mon, 22 Jul 2013 18:02:42 +0000 (-0600) Subject: Avoid invalid fileno assertion when purging victim becomes negative on overflows. X-Git-Tag: SQUID_3_5_0_1~444^2~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=02458e9bf7299a32bc10ffb67562b42cbf492771;p=thirdparty%2Fsquid.git Avoid invalid fileno assertion when purging victim becomes negative on overflows. Overflows are expected by design, but we should not allow the value to become negative. --- diff --git a/src/ipc/StoreMap.cc b/src/ipc/StoreMap.cc index 09791b2721..f27364ebce 100644 --- a/src/ipc/StoreMap.cc +++ b/src/ipc/StoreMap.cc @@ -352,7 +352,7 @@ Ipc::StoreMap::purgeOne() const int searchLimit = min(10000, entryLimit()); int tries = 0; for (; tries < searchLimit; ++tries) { - const sfileno fileno = shared->victim++ % shared->limit; + const sfileno fileno = static_cast(++shared->victim % shared->limit); assert(valid(fileno)); Anchor &s = shared->slots[fileno].anchor; if (s.lock.lockExclusive()) { diff --git a/src/ipc/StoreMap.h b/src/ipc/StoreMap.h index 720fc84b68..d441c858ae 100644 --- a/src/ipc/StoreMap.h +++ b/src/ipc/StoreMap.h @@ -115,7 +115,7 @@ public: const int limit; ///< maximum number of store entries const size_t extrasSize; ///< size of slice extra data Atomic::Word count; ///< current number of entries - Atomic::WordT victim; ///< starting point for purge search + Atomic::WordT victim; ///< starting point for purge search Ipc::Mem::FlexibleArray slots; ///< storage };