clientv3: create keepAliveCtxCloser goroutine only if ctx can be canceled

Signed-off-by: zhangwenkang <zwenkang@vmware.com>
This commit is contained in:
zhangwenkang
2023-07-10 23:08:23 +08:00
parent d4f779a643
commit 4d7b7e5fcd

View File

@@ -294,7 +294,9 @@ func (l *lessor) KeepAlive(ctx context.Context, id LeaseID) (<-chan *LeaseKeepAl
} }
l.mu.Unlock() 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() { l.firstKeepAliveOnce.Do(func() {
go l.recvKeepAliveLoop() go l.recvKeepAliveLoop()
go l.deadlineLoop() go l.deadlineLoop()