rgw: add missing cache locking

this was overlooked when switch to the multithreaded configuration
This commit is contained in:
Yehuda Sadeh 2011-08-19 12:56:38 -07:00
parent 0b216bdc8c
commit f3396bdc50
2 changed files with 8 additions and 1 deletions

View File

@ -7,6 +7,8 @@ using namespace std;
int ObjectCache::get(string& name, ObjectCacheInfo& info, uint32_t mask)
{
Mutex::Locker l(lock);
map<string, ObjectCacheEntry>::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<string, ObjectCacheEntry>::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<string, ObjectCacheEntry>::iterator iter = cache_map.find(name);
if (iter == cache_map.end())
return;

View File

@ -104,11 +104,12 @@ struct ObjectCacheEntry {
class ObjectCache {
std::map<string, ObjectCacheEntry> cache_map;
std::list<string> lru;
Mutex lock;
void touch_lru(string& name, std::list<string>::iterator& lru_iter);
void remove_lru(string& name, std::list<string>::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);