mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
v3rpc: do not send closing event
When a watch stream closes, both of the watcher.Chan and closec will be closed. If watcher.Chan is closed, we should not send out the empty event. Sending the empty is wrong and waste a lot of CPU resources. Instead we should just return.
This commit is contained in:
parent
c400d05d0a
commit
3cf90a4dff
@ -61,7 +61,10 @@ func (ws *watchServer) Watch(stream pb.Watch_WatchServer) error {
|
||||
func sendLoop(stream pb.Watch_WatchServer, watcher storage.Watcher, closec chan struct{}) {
|
||||
for {
|
||||
select {
|
||||
case e := <-watcher.Chan():
|
||||
case e, ok := <-watcher.Chan():
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
err := stream.Send(&pb.WatchResponse{Event: &e})
|
||||
if err != nil {
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user