fix a race between transport creation and wait returning

This commit is contained in:
iamqizhao 2016-02-22 16:26:15 -08:00
parent 74d8091165
commit 0be94ab3f5
1 changed files with 2 additions and 1 deletions

View File

@ -539,8 +539,9 @@ func (cc *Conn) Wait(ctx context.Context) (transport.ClientTransport, error) {
cc.mu.Unlock()
return nil, ErrClientConnClosing
case cc.state == Ready:
ct := cc.transport
cc.mu.Unlock()
return cc.transport, nil
return ct, nil
default:
ready := cc.ready
if ready == nil {