Skip to content

Commit

Permalink
refactor transportMonitor t.error case
Browse files Browse the repository at this point in the history
  • Loading branch information
menghanl committed Jul 19, 2017
1 parent 07ef8bc commit 7f43dea
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions clientconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,28 +949,22 @@ func (ac *addrConn) transportMonitor() {
ac.adjustParams(t.GetGoAwayReason())
// If GoAway happens without any network I/O error, the underlying transport
// will be gracefully closed, and a new transport will be created.
// (the transport will be closed when all the pending RPCs finished or failed.).
// (the transport will be closed when all the pending RPCs finished or failed.)
// If GoAway and some network I/O error happen concurrently, the underlying transport
// will be closed, and a new transport will be created.
var drain bool
select {
case <-t.Error():
if err := ac.resetTransport(false); err != nil {
grpclog.Infof("get error from resetTransport %v, transportMonitor returning", err)
if err != errConnClosing {
// Keep this ac in cc.conns, to get the reason it's torn down.
ac.tearDown(err)
}
return
}
default:
if err := ac.resetTransport(true); err != nil {
grpclog.Infof("get error from resetTransport %v, transportMonitor returning", err)
if err != errConnClosing {
// Keep this ac in cc.conns, to get the reason it's torn down.
ac.tearDown(err)
}
return
drain = true
}
if err := ac.resetTransport(drain); err != nil {
grpclog.Infof("get error from resetTransport %v, transportMonitor returning", err)
if err != errConnClosing {
// Keep this ac in cc.conns, to get the reason it's torn down.
ac.tearDown(err)
}
return
}
case <-t.Error():
select {
Expand Down

0 comments on commit 7f43dea

Please sign in to comment.