From 4c64d1115aed07e6fd2e307eb35639ea504709f4 Mon Sep 17 00:00:00 2001 From: Jens Stutte Date: Fri, 25 Nov 2022 16:09:02 +0000 Subject: [PATCH] Bug 1802471 - nsHttpChannel::MaybeResolveProxyAndBeginConnect should not call BeginConnect if the handler is not active. r=necko-reviewers,kershaw Differential Revision: https://phabricator.services.mozilla.com/D163125 --- netwerk/protocol/http/nsHttpChannel.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index 9ddab2d0ef76..7c0688359823 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -6018,7 +6018,15 @@ void nsHttpChannel::MaybeResolveProxyAndBeginConnect() { return; } - rv = BeginConnect(); + if (!gHttpHandler->Active()) { + LOG( + ("nsHttpChannel::MaybeResolveProxyAndBeginConnect [this=%p] " + "Handler no longer active.\n", + this)); + rv = NS_ERROR_NOT_AVAILABLE; + } else { + rv = BeginConnect(); + } if (NS_FAILED(rv)) { CloseCacheEntry(false); Unused << AsyncAbort(rv); @@ -6069,6 +6077,9 @@ nsresult nsHttpChannel::BeginConnect() { LOG(("nsHttpChannel::BeginConnect [this=%p]\n", this)); nsresult rv; + // It is the caller's responsibility to not call us late in shutdown. + MOZ_ASSERT(gHttpHandler->Active()); + // Construct connection info object nsAutoCString host; nsAutoCString scheme;