Skip to content

Commit

Permalink
[serverWatchStream] terminate recvLoop on sws.close()
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg Guba <oleg.guba@gmail.com>
  • Loading branch information
veshij committed Oct 26, 2024
1 parent 8c162bd commit 8212b7a
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 8212b7a

Please sign in to comment.