summaryrefslogtreecommitdiffstats
path: root/src/core/net/network_delegate_qt.cpp
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2018-12-04 13:05:13 +0100
committerJüri Valdmann <juri.valdmann@qt.io>2019-01-02 10:47:46 +0000
commitd8eaae80844eed5be48a606f2c604157c9cba7b4 (patch)
tree3c432d88667a6676460c63cdf33a4828b2a423cb /src/core/net/network_delegate_qt.cpp
parent024aef49ee324bf45c29e85c9a637b1495292503 (diff)
Lock profile mutex during interceptRequest
This makes setRequestInterceptor take effect atomically, so it's always safe to delete the interceptor after unsetting it from the profile. On the other hand, we run into a deadlock if the user code tries to wait for a profile operation on the UI thread to finish. It seems quite unlikely though that user code would do that and it would probably still be easier for users to understand and debug than the current non-deterministic use-after-free problems. Task-number: QTBUG-72260 Change-Id: I1784a9d9f00029d440508f0bb076d1081a326758 Reviewed-by: Michal Klocek <michal.klocek@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Diffstat (limited to 'src/core/net/network_delegate_qt.cpp')
-rw-r--r--src/core/net/network_delegate_qt.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/core/net/network_delegate_qt.cpp b/src/core/net/network_delegate_qt.cpp
index 551302291..91e3fa138 100644
--- a/src/core/net/network_delegate_qt.cpp
+++ b/src/core/net/network_delegate_qt.cpp
@@ -225,7 +225,7 @@ int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, net::Complet
const QUrl qUrl = toQt(request->url());
- QWebEngineUrlRequestInterceptor* interceptor = m_profileIOData->requestInterceptor();
+ QWebEngineUrlRequestInterceptor* interceptor = m_profileIOData->acquireInterceptor();
if (interceptor) {
QWebEngineUrlRequestInfoPrivate *infoPrivate = new QWebEngineUrlRequestInfoPrivate(toQt(resourceType),
toQt(navigationType),
@@ -234,6 +234,7 @@ int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, net::Complet
QByteArray::fromStdString(request->method()));
QWebEngineUrlRequestInfo requestInfo(infoPrivate);
interceptor->interceptRequest(requestInfo);
+ m_profileIOData->releaseInterceptor();
if (requestInfo.changed()) {
int result = infoPrivate->shouldBlockRequest ? net::ERR_BLOCKED_BY_CLIENT : net::OK;
@@ -249,7 +250,8 @@ int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, net::Complet
if (result != net::OK)
return result;
}
- }
+ } else
+ m_profileIOData->releaseInterceptor();
if (!resourceInfo)
return net::OK;