From 9dbd95fe38b74ae6efe18692fc83e021b3976de6 Mon Sep 17 00:00:00 2001 From: iamqizhao Date: Wed, 24 Aug 2016 11:02:18 -0700 Subject: [PATCH] make the test failure consistent --- clientconn.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/clientconn.go b/clientconn.go index 8c6af633..91b042fc 100644 --- a/clientconn.go +++ b/clientconn.go @@ -298,13 +298,15 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (*Clien case <-ctx.Done(): return nil, ctx.Err() case err := <-waitC: + select { + case <-ctx.Done(): + return nil, ctx.Err() + default: + } if err != nil { cc.Close() return nil, err } - case <-cc.ctx.Done(): - cc.Close() - return nil, cc.ctx.Err() case <-timeoutCh: cc.Close() return nil, ErrClientConnTimeout