Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Unified Diff: impl/memory/memcache.go

Issue 2554793002: impl/memory: Fix memcache stats race. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/memcache.go
diff --git a/impl/memory/memcache.go b/impl/memory/memcache.go
index 9e2d55c84a72912c5dd9d27f16a4712e6867f732..624617b6fcab37b72a4d6ddadc7237a19dea2cc4 100644
--- a/impl/memory/memcache.go
+++ b/impl/memory/memcache.go
@@ -78,7 +78,7 @@ func (m *mcDataItem) toUserItem(key string) *mcItem {
}
type memcacheData struct {
- lock sync.RWMutex
+ lock sync.Mutex
items map[string]*mcDataItem
casID uint64
@@ -258,8 +258,8 @@ func (m *memcacheImpl) GetMulti(keys []string, cb mc.RawItemCB) error {
for i, k := range keys {
itms[i], errs[i] = func() (mc.Item, error) {
- m.data.lock.RLock()
- defer m.data.lock.RUnlock()
+ m.data.lock.Lock()
+ defer m.data.lock.Unlock()
val, err := m.data.retrieveLocked(now, k)
if err != nil {
return nil, err
@@ -345,8 +345,8 @@ func (m *memcacheImpl) Increment(key string, delta int64, initialValue *uint64)
}
func (m *memcacheImpl) Stats() (*mc.Statistics, error) {
- m.data.lock.RLock()
- defer m.data.lock.RUnlock()
+ m.data.lock.Lock()
+ defer m.data.lock.Unlock()
ret := m.data.stats
return &ret, nil
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698