From 30426eb755168edb9f688e47c324ad54e2a3a3d7 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 --- clientv3/lease.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clientv3/lease.go b/clientv3/lease.go index c2796fc969a..cf17f7402f2 100644 --- a/clientv3/lease.go +++ b/clientv3/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()