Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 91c4d92

Browse files
committed
Bug 1768250 - Don't always do 0RTT for HTTP/2, r=necko-reviewers,dragana
Differential Revision: https://phabricator.services.mozilla.com/D148513
1 parent 137b76a commit 91c4d92

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

modules/libpref/init/StaticPrefList.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11595,6 +11595,12 @@
1159511595
value: 5
1159611596
mirror: always
1159711597

11598+
# If true, remove the resumption token when 0RTT failed.
11599+
- name: network.http.remove_resumption_token_when_early_data_failed
11600+
type: RelaxedAtomicBool
11601+
value: true
11602+
mirror: always
11603+
1159811604
# The maximum count that we allow socket prrocess to crash. If this count is
1159911605
# reached, we won't use networking over socket process.
1160011606
- name: network.max_socket_process_failed_count

netwerk/protocol/http/nsHttpTransaction.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "Http2ConnectTransaction.h"
1717
#include "base/basictypes.h"
1818
#include "mozilla/Components.h"
19+
#include "mozilla/net/SSLTokensCache.h"
1920
#include "mozilla/ScopeExit.h"
2021
#include "mozilla/Tokenizer.h"
2122
#include "mozilla/StaticPrefs_network.h"
@@ -1324,6 +1325,23 @@ bool nsHttpTransaction::ShouldRestartOn0RttError(nsresult reason) {
13241325
mEarlyDataWasAvailable && SecurityErrorThatMayNeedRestart(reason);
13251326
}
13261327

1328+
static void MaybeRemoveSSLToken(nsISSLSocketControl* aSocketControl) {
1329+
if (!StaticPrefs::
1330+
network_http_remove_resumption_token_when_early_data_failed()) {
1331+
return;
1332+
}
1333+
1334+
nsCOMPtr<nsITransportSecurityInfo> info(do_QueryInterface(aSocketControl));
1335+
if (!info) {
1336+
return;
1337+
}
1338+
1339+
nsAutoCString key;
1340+
info->GetPeerId(key);
1341+
nsresult rv = SSLTokensCache::RemoveAll(key);
1342+
LOG(("RemoveSSLToken [key=%s, rv=%" PRIx32 "]", key.get(), rv));
1343+
}
1344+
13271345
void nsHttpTransaction::Close(nsresult reason) {
13281346
LOG(("nsHttpTransaction::Close [this=%p reason=%" PRIx32 "]\n", this,
13291347
static_cast<uint32_t>(reason)));
@@ -1457,6 +1475,7 @@ void nsHttpTransaction::Close(nsresult reason) {
14571475
}
14581476

14591477
mDoNotTryEarlyData = true;
1478+
14601479
// reallySentData is meant to separate the instances where data has
14611480
// been sent by this transaction but buffered at a higher level while
14621481
// a TLS session (perhaps via a tunnel) is setup.
@@ -1751,6 +1770,10 @@ nsresult nsHttpTransaction::Restart() {
17511770
nsCOMPtr<nsISeekableStream> seekable = do_QueryInterface(mRequestStream);
17521771
if (seekable) seekable->Seek(nsISeekableStream::NS_SEEK_SET, 0);
17531772

1773+
if (mDoNotTryEarlyData) {
1774+
MaybeRemoveSSLToken(mTLSSocketControl);
1775+
}
1776+
17541777
// clear old connection state...
17551778
{
17561779
MutexAutoLock lock(mLock);

0 commit comments

Comments
 (0)