From 21eb8d2c3bb48b9a8d0454bdac5e30774d9ea0f0 Mon Sep 17 00:00:00 2001 From: zhangwenkang Date: Mon, 10 Jul 2023 01:11: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 60d7dd18e83..abdf415762d 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()