Skip to content

Commit

Permalink
grpc: read the service config channel once instead of twice (#6186)
Browse files Browse the repository at this point in the history
  • Loading branch information
easwars authored Apr 11, 2023
1 parent 6237dfe commit 89ec960
Show file tree
Hide file tree
Showing 3 changed files with 457 additions and 438 deletions.
15 changes: 1 addition & 14 deletions clientconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,19 +244,6 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *
}
}()

scSet := false
if cc.dopts.scChan != nil {
// Try to get an initial service config.
select {
case sc, ok := <-cc.dopts.scChan:
if ok {
cc.sc = &sc
cc.safeConfigSelector.UpdateConfigSelector(&defaultConfigSelector{&sc})
scSet = true
}
default:
}
}
if cc.dopts.bs == nil {
cc.dopts.bs = backoff.DefaultExponential
}
Expand All @@ -272,7 +259,7 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *
}
channelz.Infof(logger, cc.channelzID, "Channel authority set to %q", cc.authority)

if cc.dopts.scChan != nil && !scSet {
if cc.dopts.scChan != nil {
// Blocking wait for the initial service config.
select {
case sc, ok := <-cc.dopts.scChan:
Expand Down
Loading

0 comments on commit 89ec960

Please sign in to comment.