Browse Source

Merge pull request #3972 from xiang90/fix_race

store: fix data race when modify event in watchHub.
Xiang Li 10 years ago
parent
commit
833c934bd4
1 changed files with 3 additions and 2 deletions
  1. 3 2
      store/watcher_hub.go

+ 3 - 2
store/watcher_hub.go

@@ -78,8 +78,9 @@ func (wh *watcherHub) watch(key string, recursive, stream bool, index, storeInde
 	defer wh.mutex.Unlock()
 	// If the event exists in the known history, append the EtcdIndex and return immediately
 	if event != nil {
-		event.EtcdIndex = storeIndex
-		w.eventChan <- event
+		ne := event.Clone()
+		ne.EtcdIndex = storeIndex
+		w.eventChan <- ne
 		return w, nil
 	}