From 08b3e191851039bbf5d1913d7bc7785bec90c242 Mon Sep 17 00:00:00 2001 From: iamqizhao Date: Mon, 3 Aug 2015 11:29:27 -0700 Subject: [PATCH] add a shortcut logic --- clientconn.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clientconn.go b/clientconn.go index 5b8d76a7..766d758d 100644 --- a/clientconn.go +++ b/clientconn.go @@ -238,6 +238,9 @@ func (cc *ClientConn) WaitForStateChange(timeout time.Duration, sourceState Conn } done := make(chan struct{}) expired := timeout <= time.Since(start) + if expired { + return false + } go func() { select { case <-time.After(timeout-time.Since(start)):