From: Yehuda Sadeh Date: Fri, 19 Aug 2011 19:56:38 +0000 (-0700) Subject: rgw: add missing cache locking X-Git-Tag: v0.34~37 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f3396bdc50d28fe623121a50dc37cb3bc8969eb1;p=ceph.git rgw: add missing cache locking this was overlooked when switch to the multithreaded configuration --- diff --git a/src/rgw/rgw_cache.cc b/src/rgw/rgw_cache.cc index 4dde65ffe099..526e6917db3e 100644 --- a/src/rgw/rgw_cache.cc +++ b/src/rgw/rgw_cache.cc @@ -7,6 +7,8 @@ using namespace std; int ObjectCache::get(string& name, ObjectCacheInfo& info, uint32_t mask) { + Mutex::Locker l(lock); + map::iterator iter = cache_map.find(name); if (iter == cache_map.end()) { RGW_LOG(10) << "cache get: name=" << name << " : miss" << dendl; @@ -29,6 +31,8 @@ int ObjectCache::get(string& name, ObjectCacheInfo& info, uint32_t mask) void ObjectCache::put(string& name, ObjectCacheInfo& info) { + Mutex::Locker l(lock); + RGW_LOG(10) << "cache put: name=" << name << dendl; map::iterator iter = cache_map.find(name); if (iter == cache_map.end()) { @@ -67,6 +71,8 @@ void ObjectCache::put(string& name, ObjectCacheInfo& info) void ObjectCache::remove(string& name) { + Mutex::Locker l(lock); + map::iterator iter = cache_map.find(name); if (iter == cache_map.end()) return; diff --git a/src/rgw/rgw_cache.h b/src/rgw/rgw_cache.h index 9bd8af9cfc96..f3924266f25a 100644 --- a/src/rgw/rgw_cache.h +++ b/src/rgw/rgw_cache.h @@ -104,11 +104,12 @@ struct ObjectCacheEntry { class ObjectCache { std::map cache_map; std::list lru; + Mutex lock; void touch_lru(string& name, std::list::iterator& lru_iter); void remove_lru(string& name, std::list::iterator& lru_iter); public: - ObjectCache() { } + ObjectCache() : lock("ObjectCache") { } int get(std::string& name, ObjectCacheInfo& bl, uint32_t mask); void put(std::string& name, ObjectCacheInfo& bl); void remove(std::string& name);