diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-05-06 14:27:19 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-05-06 13:10:17 +0000 |
commit | 7a5f9b62cca4f65b2194c6b842be323ad4c312ff (patch) | |
tree | e7e298a859ca43282f2f9002abdf24f2f9210ce7 /src/core | |
parent | 3da7df93366b05bccbd319fd4232574722866b6c (diff) |
Fix crash when updating a storage context with active requests
Requests keep pointers to objects owneded by the storage context such
as the SSL context handler and HTTP cache. This means we must stop
all requests before destroying the context, otherwise the requests
will access deleted data.
Change-Id: I67863287b3ffb470c8d84ff6cac143493998a6da
Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/url_request_context_getter_qt.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp index dec6b4dbb..4f893175a 100644 --- a/src/core/url_request_context_getter_qt.cpp +++ b/src/core/url_request_context_getter_qt.cpp @@ -124,6 +124,18 @@ void URLRequestContextGetterQt::generateStorage() { Q_ASSERT(m_urlRequestContext); + if (m_storage) { + // We must stop all requests before deleting their backends. + std::set<const net::URLRequest*>* url_requests = m_urlRequestContext->url_requests(); + std::set<const net::URLRequest*>::const_iterator it = url_requests->begin(); + std::set<const net::URLRequest*>::const_iterator end = url_requests->end(); + for ( ; it != end; ++it) { + net::URLRequest* request = const_cast<net::URLRequest*>(*it); + if (request) + request->Cancel(); + } + } + m_storage.reset(new net::URLRequestContextStorage(m_urlRequestContext.get())); net::ProxyConfigService *proxyConfigService = m_proxyConfigService.fetchAndStoreAcquire(0); |