瀏覽代碼

Merge pull request #5404 from gyuho/watch_optimize

mvcc: remove defer in watchable store
Gyu-Ho Lee 9 年之前
父節點
當前提交
8c17674cda
共有 1 個文件被更改,包括 3 次插入5 次删除
  1. 3 5
      mvcc/watchable_store.go

+ 3 - 5
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.
 	})