Make initial service config non-blocking in Dial()

This commit is contained in:
Yuxuan Li 2017-04-05 11:08:50 -07:00
parent ad16b942fb
commit a66f9231a8
2 changed files with 7 additions and 8 deletions

View File

@ -356,14 +356,13 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *
}() }()
if cc.dopts.scChan != nil { if cc.dopts.scChan != nil {
// Wait for the initial service config. // Try to get an initial service config.
select { select {
case sc, ok := <-cc.dopts.scChan: case sc, ok := <-cc.dopts.scChan:
if ok { if ok {
cc.sc = sc cc.sc = sc
} }
case <-ctx.Done(): default:
return nil, ctx.Err()
} }
} }
// Set defaults. // Set defaults.

View File

@ -1450,12 +1450,12 @@ func testServiceConfigMaxMsgSize(t *testing.T, e env) {
wg.Wait() wg.Wait()
} }
func TestMsgSizeDefaultAndApi(t *testing.T) { func TestMsgSizeDefaultAndAPI(t *testing.T) {
defer leakCheck(t)() defer leakCheck(t)()
for _, e := range listTestEnv() { for _, e := range listTestEnv() {
testMaxMsgSizeClientDefault(t, e) testMaxMsgSizeClientDefault(t, e)
testMaxMsgSizeClientApi(t, e) testMaxMsgSizeClientAPI(t, e)
testMaxMsgSizeServerApi(t, e) testMaxMsgSizeServerAPI(t, e)
} }
} }
@ -1538,7 +1538,7 @@ func testMaxMsgSizeClientDefault(t *testing.T, e env) {
} }
} }
func testMaxMsgSizeClientApi(t *testing.T, e env) { func testMaxMsgSizeClientAPI(t *testing.T, e env) {
te := newTest(t, e) te := newTest(t, e)
te.userAgent = testAppUA te.userAgent = testAppUA
// To avoid error on server side. // To avoid error on server side.
@ -1619,7 +1619,7 @@ func testMaxMsgSizeClientApi(t *testing.T, e env) {
} }
} }
func testMaxMsgSizeServerApi(t *testing.T, e env) { func testMaxMsgSizeServerAPI(t *testing.T, e env) {
te := newTest(t, e) te := newTest(t, e)
te.userAgent = testAppUA te.userAgent = testAppUA
te.maxServerReceiveMsgSize = 1024 te.maxServerReceiveMsgSize = 1024