From f4b89fe44f0e457d5f4251e0c1978c78f97ac987 Mon Sep 17 00:00:00 2001 From: iamqizhao Date: Fri, 13 May 2016 13:27:35 -0700 Subject: [PATCH] some fixes --- clientconn.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/clientconn.go b/clientconn.go index 040ca830..723b2882 100644 --- a/clientconn.go +++ b/clientconn.go @@ -233,7 +233,6 @@ func Dial(target string, opts ...DialOption) (*ClientConn, error) { cc.balancer = RoundRobin() } - // Start the first connection if cc.dopts.resolver == nil { addr := Address{ Addr: cc.target, @@ -251,10 +250,11 @@ func Dial(target string, opts ...DialOption) (*ClientConn, error) { return nil, err } cc.watcher = w - // Get the initial name resolution which starts dialing. + // Get the initial name resolution and dial the first connection. if err := cc.watchAddrUpdates(); err != nil { return nil, err } + // Start a goroutine to watch for the future name resolution changes. go func() { for { if err := cc.watchAddrUpdates(); err != nil { @@ -338,7 +338,6 @@ func (cc *ClientConn) watchAddrUpdates() error { cc.mu.Unlock() ac, err := cc.newAddrConn(addr) if err != nil { - cc.mu.Unlock() return err } cc.mu.Lock() @@ -359,7 +358,6 @@ func (cc *ClientConn) watchAddrUpdates() error { delete(cc.conns, addr) cc.mu.Unlock() ac.tearDown(ErrConnDrain) - //ac.startDrain() default: grpclog.Println("Unknown update.Op ", update.Op) }