Bug 1647985 - Use shorter ping timeout for the connection to TRR, r=necko-reviewers,valentin

Differential Revision: https://phabricator.services.mozilla.com/D172169
This commit is contained in:
Kershaw Chang 2023-03-14 10:19:34 +00:00
parent 2888208dad
commit 56321b60eb
3 changed files with 33 additions and 3 deletions

View File

@ -11809,6 +11809,13 @@
value: 30000
mirror: always
# Similar to network.http.http2.ping-timeout, but this is used when the
# Http/2 connection is connected to the TRR server.
- name: network.trr.ping_timeout
type: RelaxedAtomicUint32
value: 3000
mirror: always
# The timeout of the TRR confirmation request
- name: network.trr.confirmation_timeout_ms
type: RelaxedAtomicUint32

View File

@ -359,11 +359,29 @@ uint32_t Http2Session::ReadTimeoutTick(PRIntervalTime now) {
}
if (mPingSentEpoch) {
LOG3(("Http2Session::ReadTimeoutTick %p handle outstanding ping\n", this));
if ((now - mPingSentEpoch) >= gHttpHandler->SpdyPingTimeout()) {
bool isTrr = (mTrrStreams > 0);
uint32_t pingTimeout = isTrr ? StaticPrefs::network_trr_ping_timeout()
: gHttpHandler->SpdyPingTimeout();
LOG3(
("Http2Session::ReadTimeoutTick %p handle outstanding ping, "
"timeout=%d\n",
this, pingTimeout));
if ((now - mPingSentEpoch) >= pingTimeout) {
LOG3(("Http2Session::ReadTimeoutTick %p Ping Timer Exhaustion\n", this));
mPingSentEpoch = 0;
Close(NS_ERROR_NET_TIMEOUT);
if (isTrr) {
// These must be set this way to ensure we gracefully restart all
// streams
mGoAwayID = 0;
mCleanShutdown = true;
// If TRR is mode 2, this Http2Session will be closed due to TRR request
// timeout, so we won't reach this code. If we are in mode 3, the
// request timeout is usually larger than the ping timeout. We close the
// stream with NS_ERROR_NET_RESET, so the transactions can be restarted.
Close(NS_ERROR_NET_RESET);
} else {
Close(NS_ERROR_NET_TIMEOUT);
}
return UINT32_MAX;
}
return 1; // run the tick aggressively while ping is outstanding
@ -4323,6 +4341,9 @@ void Http2Session::SendPing() {
mPreviousPingThreshold = mPingThreshold;
mPreviousUsed = true;
mPingThreshold = gHttpHandler->NetworkChangedTimeout();
// Reset mLastReadEpoch, so we can really check when do we got pong from the
// server.
mLastReadEpoch = 0;
}
GeneratePing(false);
Unused << ResumeRecv();

View File

@ -2381,6 +2381,8 @@ void nsHttpConnectionMgr::OnMsgVerifyTraffic(int32_t, ARefBase*) {
} else {
NS_WARNING("failed to create timer for VerifyTraffic!");
}
// Calling ActivateTimeoutTick to ensure the next timeout tick is 1s.
ActivateTimeoutTick();
}
void nsHttpConnectionMgr::OnMsgDoShiftReloadConnectionCleanup(int32_t,