From ac9801f5702045badcf9b4dbff00cf469dd148c0 Mon Sep 17 00:00:00 2001 From: Mairbek Khadikov Date: Thu, 15 Aug 2013 23:06:08 +0300 Subject: [PATCH] Concurrent GET requests should not block. --- store/store.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/store/store.go b/store/store.go index c9c2b0626..5447649c0 100644 --- a/store/store.go +++ b/store/store.go @@ -27,7 +27,7 @@ type Store struct { // the watching condition. // It is needed so that clone() can atomically replicate the Store // and do the log snapshot in a go routine. - mutex sync.Mutex + mutex sync.RWMutex // WatcherHub is where we register all the clients // who issue a watch request @@ -304,8 +304,8 @@ func (s *Store) internalGet(key string) *Response { // If key is a file return the file // If key is a directory reuturn an array of files func (s *Store) Get(key string) ([]byte, error) { - s.mutex.Lock() - defer s.mutex.Unlock() + s.mutex.RLock() + defer s.mutex.RUnlock() resps, err := s.RawGet(key)