Skip to content

Commit

Permalink
Merge pull request #18739 from veshij/leak_fix
Browse files Browse the repository at this point in the history
etcdserver: terminate recvLoop on serverWatchStream.close()
  • Loading branch information
serathius authored Oct 24, 2024
2 parents 38c27a4 + 7760735 commit 6d2b232
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 6d2b232

Please sign in to comment.