Skip to content

Commit

Permalink
[serverWatchStream] terminate recvLoop on sws.close()
Browse files Browse the repository at this point in the history
  • Loading branch information
veshij committed Oct 14, 2024
1 parent 04efee2 commit cf4510a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/etcdserver/api/v3rpc/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,17 @@ func (sws *serverWatchStream) recvLoop() error {
id := uv.CancelRequest.WatchId
err := sws.watchStream.Cancel(mvcc.WatchID(id))
if err == nil {
sws.ctrlStream <- &pb.WatchResponse{
wr := &pb.WatchResponse{
Header: sws.newResponseHeader(sws.watchStream.Rev()),
WatchId: id,
Canceled: true,
}
select {
case sws.ctrlStream <- wr:
case <-sws.closec:
return nil
}

sws.mu.Lock()
delete(sws.progress, mvcc.WatchID(id))
delete(sws.prevKV, mvcc.WatchID(id))
Expand Down

0 comments on commit cf4510a

Please sign in to comment.