Merge pull request #117 from mairbek/locking

Concurrent GET requests should not block.
release-0.4
Xiang Li 2013-08-15 13:27:55 -07:00
commit 22b943e35c
1 changed files with 3 additions and 3 deletions

View File

@ -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)