TUN-5285: Fallback to HTTP2 immediately if connection times out with no network activity

This commit is contained in:
Sudarsan Reddy
2021-11-03 12:06:04 +00:00
parent 36479ef11f
commit 0146a8d8ed
3 changed files with 23 additions and 9 deletions

View File

@@ -190,7 +190,13 @@ func ServeTunnelLoop(
case <-gracefulShutdownC:
return nil
case <-protocolFallback.BackoffTimer():
if !selectNextProtocol(&connLog, protocolFallback, config.ProtocolSelector) {
var idleTimeoutError *quic.IdleTimeoutError
if !selectNextProtocol(
&connLog,
protocolFallback,
config.ProtocolSelector,
errors.As(err, &idleTimeoutError),
) {
return err
}
}
@@ -222,8 +228,9 @@ func selectNextProtocol(
connLog *zerolog.Logger,
protocolBackoff *protocolFallback,
selector connection.ProtocolSelector,
isNetworkActivityTimeout bool,
) bool {
if protocolBackoff.ReachedMaxRetries() {
if protocolBackoff.ReachedMaxRetries() || isNetworkActivityTimeout {
fallback, hasFallback := selector.Fallback()
if !hasFallback {
return false