Changeset 279864 in webkit


Ignore:
Timestamp:
Jul 12, 2021, 9:39:26 PM (4 years ago)
Author:
Fujii Hironori
Message:

[curl] Can't finish loading some websites after r271946 started throttling low priority resources
https://bugs.webkit.org/show_bug.cgi?id=227863

Reviewed by Don Olmstead.

NetworkLoadScheduler started throttling low priority resource
loading since r271946. It uses curl_easy_pause to pause the
resource loads. CURLMOPT_MAX_HOST_CONNECTIONS is set to 6 to limit
the number of connections per host. In the certain condition,
curl_multi_fdset can constantly return -1 if 6 handles of the same
host are paused.

This patch changes CurlRequest::start not to actually start the
job if it is suspended.

  • platform/network/curl/CurlRequest.cpp:

(WebCore::CurlRequest::start):
(WebCore::CurlRequest::suspend):
(WebCore::CurlRequest::resume):
(WebCore::CurlRequest::setupTransfer):
(WebCore::CurlRequest::setRequestPaused):

  • platform/network/curl/CurlRequest.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r279854 r279864  
     12021-07-12  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [curl] Can't finish loading some websites after r271946 started throttling low priority resources
     4        https://bugs.webkit.org/show_bug.cgi?id=227863
     5
     6        Reviewed by Don Olmstead.
     7
     8        NetworkLoadScheduler started throttling low priority resource
     9        loading since r271946. It uses curl_easy_pause to pause the
     10        resource loads. CURLMOPT_MAX_HOST_CONNECTIONS is set to 6 to limit
     11        the number of connections per host. In the certain condition,
     12        curl_multi_fdset can constantly return -1 if 6 handles of the same
     13        host are paused.
     14
     15        This patch changes CurlRequest::start not to actually start the
     16        job if it is suspended.
     17
     18        * platform/network/curl/CurlRequest.cpp:
     19        (WebCore::CurlRequest::start):
     20        (WebCore::CurlRequest::suspend):
     21        (WebCore::CurlRequest::resume):
     22        (WebCore::CurlRequest::setupTransfer):
     23        (WebCore::CurlRequest::setRequestPaused):
     24        * platform/network/curl/CurlRequest.h:
     25
    1262021-07-12  Tim Horton  <timothy_horton@apple.com>
    227
  • trunk/Source/WebCore/platform/network/curl/CurlRequest.cpp

    r278391 r279864  
    4747    , m_messageQueue(WTFMove(messageQueue))
    4848    , m_request(request.isolatedCopy())
    49     , m_shouldSuspend(shouldSuspend == ShouldSuspend::Yes)
     49    , m_startState(shouldSuspend == ShouldSuspend::Yes ? StartState::StartSuspended : StartState::WaitingForStart)
    5050    , m_enableMultipart(enableMultipart == EnableMultipart::Yes)
    5151    , m_formDataStream(m_request.httpBody())
     
    111111    ASSERT(isMainThread());
    112112
     113    switch (m_startState) {
     114    case StartState::DidStart:
     115        ASSERT(false);
     116        [[fallthrough]];
     117    case StartState::StartSuspended:
     118        return;
     119    }
     120
     121    m_startState = StartState::DidStart;
     122
    113123    if (m_request.url().isLocalFile())
    114124        invokeDidReceiveResponseForFile(m_request.url());
     
    142152            didCancelTransfer();
    143153        });
    144     } else
     154    } else if (m_startState == StartState::DidStart)
    145155        scheduler.cancel(this);
    146156
     
    164174    ASSERT(isMainThread());
    165175
    166     setRequestPaused(true);
     176    switch (m_startState) {
     177    case StartState::StartSuspended:
     178        ASSERT(false);
     179        [[fallthrough]];
     180    case StartState::WaitingForStart:
     181        m_startState = StartState::StartSuspended;
     182        break;
     183    case StartState::DidStart:
     184        setRequestPaused(true);
     185        break;
     186    }
    167187}
    168188
     
    171191    ASSERT(isMainThread());
    172192
    173     setRequestPaused(false);
     193    switch (m_startState) {
     194    case StartState::WaitingForStart:
     195        ASSERT(false);
     196        [[fallthrough]];
     197    case StartState::StartSuspended:
     198        m_startState = StartState::WaitingForStart;
     199        start();
     200        break;
     201    case StartState::DidStart:
     202        setRequestPaused(false);
     203        break;
     204    }
    174205}
    175206
     
    239270    m_curlHandle->setTimeout(timeoutInterval());
    240271
    241     if (m_shouldSuspend)
    242         setRequestPaused(true);
    243 
    244272    m_performStartTime = MonotonicTime::now();
    245273
     
    644672
    645673        auto savedState = shouldBePaused();
    646         m_shouldSuspend = m_isPausedOfRequest = paused;
     674        m_isPausedOfRequest = paused;
    647675        if (shouldBePaused() == savedState)
    648676            return;
  • trunk/Source/WebCore/platform/network/curl/CurlRequest.h

    r278391 r279864  
    176176    unsigned long m_authType { CURLAUTH_ANY };
    177177    bool m_shouldDisableServerTrustEvaluation { false };
    178     bool m_shouldSuspend { false };
    179178    bool m_enableMultipart { false };
    180179
     180    enum class StartState : uint8_t { StartSuspended, WaitingForStart, DidStart };
     181    StartState m_startState;
     182   
    181183    std::unique_ptr<CurlHandle> m_curlHandle;
    182184    CurlFormDataStream m_formDataStream;
Note: See TracChangeset for help on using the changeset viewer.