Explorar el Código

Merge pull request #5176 from xiang90/lease_client

clientv3: keepaliveonce should have a per call ctx
Xiang Li hace 9 años
padre
commit
9ec176a9b0
Se han modificado 1 ficheros con 4 adiciones y 1 borrados
  1. 4 1
      clientv3/lease.go

+ 4 - 1
clientv3/lease.go

@@ -250,7 +250,10 @@ func (l *lessor) keepAliveCtxCloser(id LeaseID, ctx context.Context, donec <-cha
 }
 
 func (l *lessor) keepAliveOnce(ctx context.Context, id LeaseID) (*LeaseKeepAliveResponse, error) {
-	stream, err := l.getRemote().LeaseKeepAlive(ctx)
+	cctx, cancel := context.WithCancel(ctx)
+	defer cancel()
+
+	stream, err := l.getRemote().LeaseKeepAlive(cctx)
 	if err != nil {
 		return nil, err
 	}