grpcproxy: fix race between coalesce and bcast on nextrev

coalesce was locking the target coalesce broadcast object but not the source
broadcast object resulting in a data race on the source's nextrev.
release-3.1
Anthony Romano 2016-11-30 14:56:53 -08:00
parent 98cd3fddc9
commit 60908c64a6
1 changed files with 2 additions and 0 deletions

View File

@ -59,6 +59,7 @@ func (wbs *watchBroadcasts) coalesce(wb *watchBroadcast) {
if wbswb == wb {
continue
}
wb.mu.Lock()
wbswb.mu.Lock()
// 1. check if wbswb is behind wb so it won't skip any events in wb
// 2. ensure wbswb started; nextrev == 0 may mean wbswb is waiting
@ -71,6 +72,7 @@ func (wbs *watchBroadcasts) coalesce(wb *watchBroadcast) {
wb.receivers = nil
}
wbswb.mu.Unlock()
wb.mu.Unlock()
if wb.empty() {
delete(wbs.bcasts, wb)
wb.stop()