tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit e9af221706b48ff67ec0713c5ea649bc5361804c
parent b605b7544c8ef03582599fbfbf0a8b181c5a7674
Author: Valentin Gosu <valentin.gosu@gmail.com>
Date:   Fri, 24 Oct 2025 17:12:04 +0000

Bug 1988783 - Make sure authentication prompt suspends channel by calling nsHttpChannel::Suspend r=necko-reviewers,jesup

Otherwise the cache entry writing/revalidation can be blocking other channels
loading the same URL.

Differential Revision: https://phabricator.services.mozilla.com/D269747

Diffstat:
Mnetwerk/protocol/http/nsHttpChannel.cpp | 10++++++----
Mnetwerk/protocol/http/nsHttpChannel.h | 5+++++
2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp @@ -3330,7 +3330,7 @@ nsresult nsHttpChannel::ContinueProcessResponse3(nsresult rv) { LOG( ("Suspending the transaction, asynchronously prompting for " "credentials")); - mTransactionPump->Suspend(); + Suspend(); #ifdef DEBUG // This is for test purposes only. See bug 1683176 for details. @@ -6739,7 +6739,7 @@ NS_IMETHODIMP nsHttpChannel::OnAuthAvailable() { StoreProxyAuthPending(false); LOG(("Resuming the transaction, we got credentials from user")); if (mTransactionPump) { - mTransactionPump->Resume(); + Resume(); } if (StaticPrefs::network_auth_use_redirect_for_retries()) { @@ -6781,7 +6781,7 @@ NS_IMETHODIMP nsHttpChannel::OnAuthCancelled(bool userCancel) { // may have been canceled if we don't want to show it) mAuthRetryPending = false; LOG(("Resuming the transaction, user cancelled the auth dialog")); - mTransactionPump->Resume(); + Resume(); if (NS_FAILED(rv)) mTransactionPump->Cancel(rv); } @@ -7193,8 +7193,9 @@ nsHttpChannel::Resume() { } // Reset bypass flag since the writer is resuming - if (mCacheEntry && (mWritingToCache || LoadCacheEntryIsWriteOnly())) { + if (mBypassCacheWriterSet && mCacheEntry) { mCacheEntry->SetBypassWriterLock(false); + mBypassCacheWriterSet = false; LOG((" reset bypass writer lock flag")); } @@ -11732,6 +11733,7 @@ nsresult nsHttpChannel::OnSuspendTimeout() { if (mSuspendCount > 0 && mCacheEntry) { LOG((" suspend timeout: bypassing writer lock")); mCacheEntry->SetBypassWriterLock(true); + mBypassCacheWriterSet = true; } return NS_OK; diff --git a/netwerk/protocol/http/nsHttpChannel.h b/netwerk/protocol/http/nsHttpChannel.h @@ -870,6 +870,11 @@ class nsHttpChannel final : public HttpBaseChannel, // OnCacheEntryCheck being called at the same time. mozilla::Mutex mRCWNLock MOZ_UNANNOTATED{"nsHttpChannel.mRCWNLock"}; + // Set to true when OnSuspendTimeout calls SetBypassWriterLock(true) + // for the cache entry. Gets reset back to false when Resume calls + // SetBypassWriterLock(false) + bool mBypassCacheWriterSet{false}; + TimeStamp mNavigationStartTimeStamp; // Promise that blocks connection creation when we want to resolve the origin