]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fixed Rock::DirMap::Slot::checkKey() which was ignoring its parameter.
authorAlex Rousskov <rousskov@measurement-factory.com>
Tue, 1 Feb 2011 06:41:15 +0000 (23:41 -0700)
committerAlex Rousskov <rousskov@measurement-factory.com>
Tue, 1 Feb 2011 06:41:15 +0000 (23:41 -0700)
Store entry key in four 4-byte atomics instead of two 8-byte atomics because
older GCCs (e.g., v4.4.1) lack __sync_fetch_and_add_8.

src/fs/rock/RockDirMap.cc
src/fs/rock/RockDirMap.h

index dfee698abf608054de1bf8e357ba45be3b1615c3..ac4febca7c8b6dcea129d03c10230b6be72c2f4f 100644 (file)
@@ -193,7 +193,7 @@ Rock::DirMap::freeIfNeeded(Slot &s)
         if (s.readLevel > 0) {
             assert(s.state.swap_if(Slot::Freeing, Slot::WaitingToBeFreed));
         } else {
-            memset(s.key, 0, sizeof(s.key));
+            memset(s.key_, 0, sizeof(s.key_));
             memset(&s.seBasics, 0, sizeof(s.seBasics));
             --shared->count;
             assert(s.state.swap_if(Slot::Freeing, Slot::Empty));
@@ -226,14 +226,15 @@ Rock::DirMap::SharedSize(const int limit)
 void
 Rock::DirMap::Slot::setKey(const cache_key *const aKey)
 {
-    memcpy(key, aKey, sizeof(key));
+    memcpy(key_, aKey, sizeof(key_));
 }
 
 bool
 Rock::DirMap::Slot::checkKey(const cache_key *const aKey) const
 {
-    const uint64_t *const k = reinterpret_cast<const uint64_t *>(&key);
-    return k[0] == key[0] && k[1] == key[1];
+    const uint32_t *const k = reinterpret_cast<const uint32_t *>(aKey);
+    return k[0] == key_[0] && k[1] == key_[1] &&
+           k[2] == key_[2] && k[3] == key_[3];
 }
 
 Rock::DirMap::Shared::Shared(const int aLimit): limit(aLimit), count(0)
index a083b5eefa4d629a229240b2556e6d427190e21f..4f0e56e6912828dd614342c3e77496fff9745701 100644 (file)
@@ -66,7 +66,10 @@ private:
 
         AtomicWordT<uint8_t> state; ///< slot state
         AtomicWord readLevel; ///< read level
-        AtomicWordT<uint64_t> key[2]; ///< MD5 entry key
+
+        // we want two uint64_t, but older GCCs lack __sync_fetch_and_add_8
+        AtomicWordT<uint32_t> key_[4]; ///< MD5 entry key
+
         StoreEntryBasics seBasics; ///< basic store entry data
     };