summaryrefslogtreecommitdiffstats
path: root/WebKit/android/WebCoreSupport/WebRequest.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-08-19 17:50:16 +0100
committerSteve Block <steveblock@google.com>2010-08-19 19:07:00 +0100
commit966b9a655808c34536934bd808630798fbb201b5 (patch)
tree01ef1431802d0a54cce6106bf759bc4e1040bf2e /WebKit/android/WebCoreSupport/WebRequest.cpp
parenta49e216a2b9e2243bdeb847a5ebb66a0a291b902 (diff)
downloadexternal_webkit-966b9a655808c34536934bd808630798fbb201b5.zip
external_webkit-966b9a655808c34536934bd808630798fbb201b5.tar.gz
external_webkit-966b9a655808c34536934bd808630798fbb201b5.tar.bz2
Fixes a race condition in the Chrome HTTP stack
There is a possible race condition between the IO thread finishing the request and the WebCore thread cancelling it. If the request has already finished, ignore subsequent calls to finish to avoid sending duplicate finish messages to WebCore. Change-Id: I44f61c1b29baef686e59b66b40b32d9b1d9699c2
Diffstat (limited to 'WebKit/android/WebCoreSupport/WebRequest.cpp')
-rw-r--r--WebKit/android/WebCoreSupport/WebRequest.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/WebKit/android/WebCoreSupport/WebRequest.cpp b/WebKit/android/WebCoreSupport/WebRequest.cpp
index 9118baf..79e780e 100644
--- a/WebKit/android/WebCoreSupport/WebRequest.cpp
+++ b/WebKit/android/WebCoreSupport/WebRequest.cpp
@@ -51,7 +51,6 @@ namespace {
WebRequest::WebRequest(WebUrlLoaderClient* loader, WebResourceRequest webResourceRequest)
: m_urlLoader(loader)
- , m_request(0)
{
GURL gurl(webResourceRequest.url());
m_request = new URLRequest(gurl, this);
@@ -81,6 +80,7 @@ void WebRequest::finish(bool success)
void WebRequest::AppendBytesToUpload(const char* bytes, int bytesLen)
{
+ // This should always be called after start and before finish.
m_request->AppendBytesToUpload(bytes, bytesLen);
}
@@ -100,8 +100,13 @@ void WebRequest::start(bool isPrivateBrowsing)
void WebRequest::cancel()
{
- if (m_request)
- m_request->Cancel();
+ // There is a possible race condition between the IO thread finishing the request and
+ // the WebCore thread cancelling it. If the request has already finished, do
+ // nothing to avoid sending duplicate finish messages to WebCore.
+ if (!m_request)
+ return;
+
+ m_request->Cancel();
finish(true);
}