Bug 1738984 - Prevent NSS initialization and channel creation during shutdown r=keeler

Differential Revision: https://phabricator.services.mozilla.com/D133065
This commit is contained in:
Valentin Gosu 2021-12-07 22:52:20 +00:00
Родитель 9c31da24d9
Коммит 2b555ca6ac
3 изменённых файлов: 17 добавлений и 0 удалений

Просмотреть файл

@ -9,6 +9,7 @@
#include "nsNetUtil.h"
#include "mozilla/AppShutdown.h"
#include "mozilla/Atomics.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/Components.h"
@ -2709,6 +2710,11 @@ void net_EnsurePSMInit() {
return;
}
// Avoid a late initialization
if (AppShutdown::IsInOrBeyond(ShutdownPhase::AppShutdownNetTeardown)) {
return;
}
MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());

Просмотреть файл

@ -66,6 +66,7 @@
#include "mozilla/net/SocketProcessParent.h"
#include "mozilla/net/SocketProcessChild.h"
#include "mozilla/ipc/URIUtils.h"
#include "mozilla/AppShutdown.h"
#include "mozilla/Telemetry.h"
#include "mozilla/Unused.h"
#include "mozilla/AntiTrackingRedirectHeuristic.h"
@ -2059,6 +2060,11 @@ nsHttpHandler::NewProxiedChannel(nsIURI* uri, nsIProxyInfo* givenProxyInfo,
httpChannel = new nsHttpChannel();
}
// Avoid a late initialization
if (AppShutdown::IsInOrBeyond(ShutdownPhase::AppShutdownNetTeardown)) {
return NS_ERROR_ILLEGAL_DURING_SHUTDOWN;
}
return SetupChannelInternal(httpChannel, uri, givenProxyInfo,
proxyResolveFlags, proxyURI, aLoadInfo, result);
}

Просмотреть файл

@ -2246,6 +2246,11 @@ nsresult nsNSSComponent::Init() {
return NS_ERROR_NOT_AVAILABLE;
}
// Avoid a late initialization
if (AppShutdown::IsInOrBeyond(ShutdownPhase::AppShutdownNetTeardown)) {
return NS_ERROR_ILLEGAL_DURING_SHUTDOWN;
}
Telemetry::AutoScalarTimer<Telemetry::ScalarID::NETWORKING_NSS_INITIALIZATION>
timer;