Skip to content

Commit

Permalink
Merge pull request etcd-io#17117 from silves-xiang/main
Browse files Browse the repository at this point in the history
etcdclient: Fix memory leak caused by for + time.After
  • Loading branch information
ahrtr authored Dec 14, 2023
2 parents a70fa9b + ed01ee1 commit 2cf112f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion client/v3/lease.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,12 @@ func (l *lessor) recvKeepAlive(resp *pb.LeaseKeepAliveResponse) {
// deadlineLoop reaps any keep alive channels that have not received a response
// within the lease TTL
func (l *lessor) deadlineLoop() {
timer := time.NewTimer(time.Second)
defer timer.Stop()
for {
timer.Reset(time.Second)
select {
case <-time.After(time.Second):
case <-timer.C:
case <-l.donec:
return
}
Expand Down

0 comments on commit 2cf112f

Please sign in to comment.