Merge pull request #17117 from silves-xiang/main

etcdclient: Fix memory leak caused by for + time.After
This commit is contained in:
Benjamin Wang 2023-12-14 15:17:58 +00:00 committed by GitHub
commit 2cf112f3b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}