From 4d7b7e5fcdad2acd2264326d78bcd1d53aa004b2 Mon Sep 17 00:00:00 2001 From: zhangwenkang Date: Mon, 10 Jul 2023 23:08:23 +0800 Subject: [PATCH] clientv3: create keepAliveCtxCloser goroutine only if ctx can be canceled Signed-off-by: zhangwenkang --- client/v3/lease.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/v3/lease.go b/client/v3/lease.go index 9e1b704648b..19af9c093a3 100644 --- a/client/v3/lease.go +++ b/client/v3/lease.go @@ -294,7 +294,9 @@ func (l *lessor) KeepAlive(ctx context.Context, id LeaseID) (<-chan *LeaseKeepAl } l.mu.Unlock() - go l.keepAliveCtxCloser(ctx, id, ka.donec) + if ctx.Done() != nil { + go l.keepAliveCtxCloser(ctx, id, ka.donec) + } l.firstKeepAliveOnce.Do(func() { go l.recvKeepAliveLoop() go l.deadlineLoop()