Title: [249105] trunk/Source/WebCore
- Revision
- 249105
- Author
- [email protected]
- Date
- 2019-08-26 10:51:18 -0700 (Mon, 26 Aug 2019)
Log Message
CacheStorageConnection::computeRealBodySize is not thread-safe
https://bugs.webkit.org/show_bug.cgi?id=201074
Reviewed by Chris Dumez.
In case of a form data, the size computation might require sync IPC to the network process which is not thread-safe
In that case, hop to the main thread to compute the size of the body.
Covered by existing service worker tests in Debug mode.
* Modules/cache/CacheStorageConnection.cpp:
(WebCore::formDataSize):
(WebCore::CacheStorageConnection::computeRealBodySize):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (249104 => 249105)
--- trunk/Source/WebCore/ChangeLog 2019-08-26 17:48:11 UTC (rev 249104)
+++ trunk/Source/WebCore/ChangeLog 2019-08-26 17:51:18 UTC (rev 249105)
@@ -1,5 +1,20 @@
2019-08-26 Youenn Fablet <[email protected]>
+ CacheStorageConnection::computeRealBodySize is not thread-safe
+ https://bugs.webkit.org/show_bug.cgi?id=201074
+
+ Reviewed by Chris Dumez.
+
+ In case of a form data, the size computation might require sync IPC to the network process which is not thread-safe
+ In that case, hop to the main thread to compute the size of the body.
+ Covered by existing service worker tests in Debug mode.
+
+ * Modules/cache/CacheStorageConnection.cpp:
+ (WebCore::formDataSize):
+ (WebCore::CacheStorageConnection::computeRealBodySize):
+
+2019-08-26 Youenn Fablet <[email protected]>
+
MessagePort should be WeakPtrFactoryInitialization::Eager
https://bugs.webkit.org/show_bug.cgi?id=201073
Modified: trunk/Source/WebCore/Modules/cache/CacheStorageConnection.cpp (249104 => 249105)
--- trunk/Source/WebCore/Modules/cache/CacheStorageConnection.cpp 2019-08-26 17:48:11 UTC (rev 249104)
+++ trunk/Source/WebCore/Modules/cache/CacheStorageConnection.cpp 2019-08-26 17:51:18 UTC (rev 249105)
@@ -33,12 +33,24 @@
namespace WebCore {
using namespace WebCore::DOMCacheEngine;
+static inline uint64_t formDataSize(const FormData& formData, PAL::SessionID sessionID)
+{
+ if (isMainThread())
+ return formData.lengthInBytes(sessionID);
+
+ uint64_t resultSize;
+ callOnMainThreadAndWait([sessionID, formData = formData.isolatedCopy(), &resultSize] {
+ resultSize = formData->lengthInBytes(sessionID);
+ });
+ return resultSize;
+}
+
uint64_t CacheStorageConnection::computeRealBodySize(const DOMCacheEngine::ResponseBody& body)
{
uint64_t result = 0;
- WTF::switchOn(body, [&] (const Ref<WebCore::FormData>& formData) {
- result = formData->lengthInBytes(sessionID());
- }, [&] (const Ref<WebCore::SharedBuffer>& buffer) {
+ WTF::switchOn(body, [&] (const Ref<FormData>& formData) {
+ result = formDataSize(formData, sessionID());
+ }, [&] (const Ref<SharedBuffer>& buffer) {
result = buffer->size();
}, [] (const std::nullptr_t&) {
});
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes