Skip to content

Commit

Permalink
Merge pull request #18784 from veshij/release-3.5
Browse files Browse the repository at this point in the history
[3.5] [serverWatchStream] terminate recvLoop on sws.close()
  • Loading branch information
ahrtr authored Oct 29, 2024
2 parents e102f29 + e590572 commit 5a5408b
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 @@ -345,11 +345,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 5a5408b

Please sign in to comment.