From 999917010dd5367cc152f201c72cc31c9c4409b4 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Fri, 3 Apr 2015 10:13:43 -0700 Subject: [PATCH] store: fix watcher removal --- etcdserver/etcdhttp/client.go | 1 - store/watcher_hub.go | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/etcdserver/etcdhttp/client.go b/etcdserver/etcdhttp/client.go index df423817f..f4a264e04 100644 --- a/etcdserver/etcdhttp/client.go +++ b/etcdserver/etcdhttp/client.go @@ -140,7 +140,6 @@ func (h *keysHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { writeError(w, err) return } - switch { case resp.Event != nil: if err := writeKeyEvent(w, resp.Event, h.timer); err != nil { diff --git a/store/watcher_hub.go b/store/watcher_hub.go index 7fd4d0c48..0a7fa3c65 100644 --- a/store/watcher_hub.go +++ b/store/watcher_hub.go @@ -84,7 +84,6 @@ func (wh *watcherHub) watch(key string, recursive, stream bool, index, storeInde if ok { // add the new watcher to the back of the list elem = l.PushBack(w) - } else { // create a new list and add the new watcher l = list.New() elem = l.PushBack(w) @@ -146,6 +145,7 @@ func (wh *watcherHub) notifyWatchers(e *Event, nodePath string, deleted bool) { // if we successfully notify a watcher // we need to remove the watcher from the list // and decrease the counter + w.removed = true l.Remove(curr) atomic.AddInt64(&wh.count, -1) }