commit | a80cf8dfe98dea3ba05dfbd2ecb54b851b22cc31 | [log] [tgz] |
---|---|---|
author | iamqizhao <toqizhao@gmail.com> | Wed Oct 07 16:56:15 2015 -0700 |
committer | iamqizhao <toqizhao@gmail.com> | Wed Oct 07 16:56:15 2015 -0700 |
tree | ce78185c60c6fab2051b62681bdc4110175e2e06 | |
parent | 8d7cb9253d459a204faa8232ff02ddf077e4acf9 [diff] |
add a mutex to guard w.kv
diff --git a/naming/etcd/etcd.go b/naming/etcd/etcd.go index 8a877ed..9072e85 100644 --- a/naming/etcd/etcd.go +++ b/naming/etcd/etcd.go
@@ -92,6 +92,7 @@ type watcher struct { wr etcdcl.Watcher + mu sync.Mutex kv map[string]string } @@ -123,6 +124,7 @@ if resp.Node.Dir { continue } + w.mu.Lock() switch resp.Action { case "set": if resp.PrevNode == nil { @@ -149,6 +151,7 @@ }) delete(w.kv, resp.Node.Key) } + w.mu.Unlock() return nu, nil } }