Procházet zdrojové kódy

mvcc: remove defer in watchable store

Gyu-Ho Lee před 9 roky
rodič
revize
aa85cf037f
1 změnil soubory, kde provedl 3 přidání a 5 odebrání
  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() {
 	cancel := cancelFunc(func() {
 		s.mu.Lock()
 		s.mu.Lock()
-		defer s.mu.Unlock()
 		// remove references of the watcher
 		// remove references of the watcher
 		if s.unsynced.delete(wa) {
 		if s.unsynced.delete(wa) {
 			slowWatcherGauge.Dec()
 			slowWatcherGauge.Dec()
 			watcherGauge.Dec()
 			watcherGauge.Dec()
-			return
-		}
-
-		if s.synced.delete(wa) {
+		} else if s.synced.delete(wa) {
 			watcherGauge.Dec()
 			watcherGauge.Dec()
 		}
 		}
+		s.mu.Unlock()
+
 		// If we cannot find it, it should have finished watch.
 		// If we cannot find it, it should have finished watch.
 	})
 	})