浏览代码

integration: close proxy's lease client

Anthony Romano 8 年之前
父节点
当前提交
2fd6df922a
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      integration/cluster_proxy.go

+ 4 - 0
integration/cluster_proxy.go

@@ -75,6 +75,7 @@ type proxyCloser struct {
 	clientv3.Watcher
 	wdonec  <-chan struct{}
 	kvdonec <-chan struct{}
+	lclose  func()
 	lpdonec <-chan struct{}
 }
 
@@ -83,6 +84,7 @@ func (pc *proxyCloser) Close() error {
 	<-pc.kvdonec
 	err := pc.Watcher.Close()
 	<-pc.wdonec
+	pc.lclose()
 	<-pc.lpdonec
 	return err
 }
@@ -95,11 +97,13 @@ func newClientV3(cfg clientv3.Config) (*clientv3.Client, error) {
 	rpc := toGRPC(c)
 	c.KV = clientv3.NewKVFromKVClient(rpc.KV)
 	pmu.Lock()
+	lc := c.Lease
 	c.Lease = clientv3.NewLeaseFromLeaseClient(rpc.Lease, cfg.DialTimeout)
 	c.Watcher = &proxyCloser{
 		Watcher: clientv3.NewWatchFromWatchClient(rpc.Watch),
 		wdonec:  proxies[c].wdonec,
 		kvdonec: proxies[c].kvdonec,
+		lclose:  func() { lc.Close() },
 		lpdonec: proxies[c].lpdonec,
 	}
 	pmu.Unlock()