mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
store: fix data race when modify event in watchHub.
The event got from watchHub should be considered as readonly. To modify it, we first need to get a clone of it or there might be a data race.
This commit is contained in:
parent
0fb2d5d4d3
commit
e0c7768f94
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user