From aa85cf037f36c01b1d420cc87d59dd9dc2e3ed9d Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Thu, 19 May 2016 13:51:51 -0700 Subject: [PATCH] mvcc: remove defer in watchable store --- mvcc/watchable_store.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mvcc/watchable_store.go b/mvcc/watchable_store.go index 0c0ba2b5e..8ba6b0005 100644 --- a/mvcc/watchable_store.go +++ b/mvcc/watchable_store.go @@ -211,17 +211,15 @@ func (s *watchableStore) watch(key, end []byte, startRev int64, id WatchID, ch c cancel := cancelFunc(func() { s.mu.Lock() - defer s.mu.Unlock() // remove references of the watcher if s.unsynced.delete(wa) { slowWatcherGauge.Dec() watcherGauge.Dec() - return - } - - if s.synced.delete(wa) { + } else if s.synced.delete(wa) { watcherGauge.Dec() } + s.mu.Unlock() + // If we cannot find it, it should have finished watch. })