From fd80e5c6534827c27ac89809bc04c607f18a75d0 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Wed, 29 May 2019 20:01:08 +0300 Subject: [PATCH] Fix assertions when shutting down with pending requests (see issue #2622). This change avoids the starting of new requests during shutdown. --- .../browser/net_service/proxy_url_loader_factory.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libcef/browser/net_service/proxy_url_loader_factory.cc b/libcef/browser/net_service/proxy_url_loader_factory.cc index 1fbc2ce45..9ef1a9762 100644 --- a/libcef/browser/net_service/proxy_url_loader_factory.cc +++ b/libcef/browser/net_service/proxy_url_loader_factory.cc @@ -5,6 +5,7 @@ #include "libcef/browser/net_service/proxy_url_loader_factory.h" +#include "libcef/browser/context.h" #include "libcef/browser/thread_util.h" #include "libcef/common/net_service/net_service_util.h" @@ -1107,6 +1108,12 @@ void ProxyURLLoaderFactory::CreateLoaderAndStart( network::mojom::URLLoaderClientPtr client, const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) { CEF_REQUIRE_IOT(); + + if (!CONTEXT_STATE_VALID()) { + // Don't start a request while we're shutting down. + return; + } + bool pass_through = false; if (pass_through) { // This is the so-called pass-through, no-op option. @@ -1138,8 +1145,8 @@ void ProxyURLLoaderFactory::OnLoaderCreated( network::mojom::TrustedHeaderClientRequest request) { CEF_REQUIRE_IOT(); auto request_it = requests_.find(request_id); - DCHECK(request_it != requests_.end()); - request_it->second->OnLoaderCreated(std::move(request)); + if (request_it != requests_.end()) + request_it->second->OnLoaderCreated(std::move(request)); } void ProxyURLLoaderFactory::OnTargetFactoryError() {