proxy/grpcproxy: Add critical section to protect wps.watchers and wps.nextWatcherID
@@ -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:
