proxy/grpcproxy: Add critical section to protect wps.watchers and wps.nextWatcherID

This commit is contained in:
Ziheng Liu 2019-08-03 18:08:02 -07:00
parent 9a2af7378a
commit a0b2c6ad4b
No known key found for this signature in database
GPG Key ID: D43CCD050419428C

View File

@ -240,6 +240,7 @@ func (wps *watchProxyStream) recvLoop() error {
continue
}
wps.mu.Lock()
w := &watcher{
wr: watchRange{string(cr.Key), string(cr.RangeEnd)},
id: wps.nextWatcherID,
@ -258,6 +259,7 @@ func (wps *watchProxyStream) recvLoop() error {
w.nextrev = cr.StartRevision
wps.watchers[w.id] = w
wps.ranges.add(w)
wps.mu.Unlock()
case *pb.WatchRequest_CancelRequest:
wps.delete(uv.CancelRequest.WatchId)
default: