⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 249105 in webkit


Ignore:
Timestamp:
Aug 26, 2019, 10:51:18 AM (7 years ago)
Author:
youenn@apple.com
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):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r249094 r249105  
     12019-08-26  Youenn Fablet  <youenn@apple.com>
     2
     3        CacheStorageConnection::computeRealBodySize is not thread-safe
     4        https://bugs.webkit.org/show_bug.cgi?id=201074
     5
     6        Reviewed by Chris Dumez.
     7
     8        In case of a form data, the size computation might require sync IPC to the network process which is not thread-safe
     9        In that case, hop to the main thread to compute the size of the body.
     10        Covered by existing service worker tests in Debug mode.
     11
     12        * Modules/cache/CacheStorageConnection.cpp:
     13        (WebCore::formDataSize):
     14        (WebCore::CacheStorageConnection::computeRealBodySize):
     15
    1162019-08-26  Youenn Fablet  <youenn@apple.com>
    217
  • trunk/Source/WebCore/Modules/cache/CacheStorageConnection.cpp

    r248670 r249105  
    3434using namespace WebCore::DOMCacheEngine;
    3535
     36static inline uint64_t formDataSize(const FormData& formData, PAL::SessionID sessionID)
     37{
     38    if (isMainThread())
     39        return formData.lengthInBytes(sessionID);
     40
     41    uint64_t resultSize;
     42    callOnMainThreadAndWait([sessionID, formData = formData.isolatedCopy(), &resultSize] {
     43        resultSize = formData->lengthInBytes(sessionID);
     44    });
     45    return resultSize;
     46}
     47
    3648uint64_t CacheStorageConnection::computeRealBodySize(const DOMCacheEngine::ResponseBody& body)
    3749{
    3850    uint64_t result = 0;
    39     WTF::switchOn(body, [&] (const Ref<WebCore::FormData>& formData) {
    40         result = formData->lengthInBytes(sessionID());
    41     }, [&] (const Ref<WebCore::SharedBuffer>& buffer) {
     51    WTF::switchOn(body, [&] (const Ref<FormData>& formData) {
     52        result = formDataSize(formData, sessionID());
     53    }, [&] (const Ref<SharedBuffer>& buffer) {
    4254        result = buffer->size();
    4355    }, [] (const std::nullptr_t&) {
Note: See TracChangeset for help on using the changeset viewer.