v3rpc: report eventReceived correctly

release-2.3
Xiang Li 2015-11-19 22:44:44 -08:00
parent 3cf90a4dff
commit b868f4b1b1
1 changed files with 9 additions and 0 deletions

View File

@ -66,10 +66,19 @@ func sendLoop(stream pb.Watch_WatchServer, watcher storage.Watcher, closec chan
return
}
err := stream.Send(&pb.WatchResponse{Event: &e})
storage.ReportEventReceived()
if err != nil {
return
}
case <-closec:
// drain the chan to clean up pending events
for {
_, ok := <-watcher.Chan()
if !ok {
return
}
storage.ReportEventReceived()
}
return
}
}