Merge pull request #10974 from lzhfromustc/watchers

proxy: Add critical section to protect wps.watchers and wps.nextWatcherID
This commit is contained in:
Xiang Li 2019-08-14 16:14:27 -07:00 committed by GitHub
commit bbb379fa4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -241,6 +241,7 @@ func (wps *watchProxyStream) recvLoop() error {
continue
}
wps.mu.Lock()
w := &watcher{
wr: watchRange{string(cr.Key), string(cr.RangeEnd)},
id: wps.nextWatcherID,
@ -259,6 +260,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: