From: Samuel Just Date: Wed, 22 Oct 2014 19:40:14 +0000 (-0700) Subject: shared_cache::add: do not delete value if existed X-Git-Tag: v0.87~4^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c116b4b55ab23bef00489db9fbff9fae6ba4bba7;p=ceph.git shared_cache::add: do not delete value if existed The method contract specifies that we do not want to delete value if we are not inserting it, so do not initialize val at the top of the function to take over value. No current users appear to trip over this problem (FDCache and map_cache). Signed-off-by: Samuel Just --- diff --git a/src/common/shared_cache.hpp b/src/common/shared_cache.hpp index a5079ede6a0c..0c4832c51647 100644 --- a/src/common/shared_cache.hpp +++ b/src/common/shared_cache.hpp @@ -209,7 +209,7 @@ public: * @return A reference to the map's value for the given key */ VPtr add(const K& key, V *value, bool *existed = NULL) { - VPtr val(value, Cleanup(this, key)); + VPtr val; list to_release; { Mutex::Locker l(lock); @@ -224,6 +224,7 @@ public: if (existed) *existed = false; + val = VPtr(value, Cleanup(this, key)); weak_refs.insert(actual, make_pair(key, val)); lru_add(key, val, &to_release); }