mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #117 from mairbek/locking
Concurrent GET requests should not block.
This commit is contained in:
commit
22b943e35c
@ -27,7 +27,7 @@ type Store struct {
|
|||||||
// the watching condition.
|
// the watching condition.
|
||||||
// It is needed so that clone() can atomically replicate the Store
|
// It is needed so that clone() can atomically replicate the Store
|
||||||
// and do the log snapshot in a go routine.
|
// and do the log snapshot in a go routine.
|
||||||
mutex sync.Mutex
|
mutex sync.RWMutex
|
||||||
|
|
||||||
// WatcherHub is where we register all the clients
|
// WatcherHub is where we register all the clients
|
||||||
// who issue a watch request
|
// 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 file return the file
|
||||||
// If key is a directory reuturn an array of files
|
// If key is a directory reuturn an array of files
|
||||||
func (s *Store) Get(key string) ([]byte, error) {
|
func (s *Store) Get(key string) ([]byte, error) {
|
||||||
s.mutex.Lock()
|
s.mutex.RLock()
|
||||||
defer s.mutex.Unlock()
|
defer s.mutex.RUnlock()
|
||||||
|
|
||||||
resps, err := s.RawGet(key)
|
resps, err := s.RawGet(key)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user