Changeset 152297 in webkit


Ignore:
Timestamp:
Jul 2, 2013 9:26:03 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[Curl] Crash after download.
https://bugs.webkit.org/show_bug.cgi?id=118303

Patch by peavo@outlook.com <peavo@outlook.com> on 2013-07-02
Reviewed by Brent Fulgham.

We need to make sure that the Curl easy handle is removed from the Curl multi handle before it's freed.

  • platform/network/curl/CurlDownload.cpp:

(CurlDownloadManager::updateHandleList): Use addToCurl() and removeFromCurl() methods.
(CurlDownloadManager::addToCurl): Add method to add easy handle to multi handle.
(CurlDownloadManager::removeFromCurl): Add method to remove easy handle from multi handle, and then delete the handle.
(CurlDownloadManager::downloadThread): Use removeFromCurl() method.
(CurlDownload::~CurlDownload):

  • platform/network/curl/CurlDownload.h: Avoid deleting Curl easy handle in destructor.
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r152293 r152297  
     12013-07-02  peavo@outlook.com  <peavo@outlook.com>
     2
     3        [Curl] Crash after download.
     4        https://bugs.webkit.org/show_bug.cgi?id=118303
     5
     6        Reviewed by Brent Fulgham.
     7
     8        We need to make sure that the Curl easy handle is removed from the Curl multi handle before it's freed.
     9
     10        * platform/network/curl/CurlDownload.cpp:
     11        (CurlDownloadManager::updateHandleList): Use addToCurl() and removeFromCurl() methods.
     12        (CurlDownloadManager::addToCurl): Add method to add easy handle to multi handle.
     13        (CurlDownloadManager::removeFromCurl): Add method to remove easy handle from multi handle, and then delete the handle.
     14        (CurlDownloadManager::downloadThread): Use removeFromCurl() method.
     15        (CurlDownload::~CurlDownload):
     16        * platform/network/curl/CurlDownload.h: Avoid deleting Curl easy handle in destructor.
     17
    1182013-07-02  Radu Stavila  <stavila@adobe.com>
    219
  • trunk/Source/WebCore/platform/network/curl/CurlDownload.cpp

    r152142 r152297  
    122122    int size = m_pendingHandleList.size();
    123123    for (int i = 0; i < size; i++) {
    124         CURLMcode retval = curl_multi_add_handle(m_curlMultiHandle, m_pendingHandleList[0]);
    125 
    126         if (retval == CURLM_OK)
     124        if (addToCurl(m_pendingHandleList[0]))
    127125            m_pendingHandleList.remove(0);
    128126    }
     
    131129    size = m_removedHandleList.size();
    132130    for (int i = 0; i < size; i++) {
    133         CURLMcode retval = curl_multi_remove_handle(m_curlMultiHandle, m_removedHandleList[0]);
    134 
    135         if (retval == CURLM_OK)
     131        if (removeFromCurl(m_removedHandleList[0]))
    136132            m_removedHandleList.remove(0);
    137133    }
     134}
     135
     136bool CurlDownloadManager::addToCurl(CURL* curlHandle)
     137{
     138    CURLMcode retval = curl_multi_add_handle(m_curlMultiHandle, curlHandle);
     139    return retval == CURLM_OK;
     140}
     141
     142bool CurlDownloadManager::removeFromCurl(CURL* curlHandle)
     143{
     144    CURLMcode retval = curl_multi_remove_handle(m_curlMultiHandle, curlHandle);
     145    if (retval == CURLM_OK) {
     146        curl_easy_cleanup(curlHandle);
     147        return true;
     148    }
     149    return false;
    138150}
    139151
     
    189201                callOnMainThread<CurlDownload*, CurlDownload*>(CurlDownload::downloadFailedCallback, download);
    190202
    191             curl_multi_remove_handle(downloadManager->getMultiHandle(), msg->easy_handle);
     203            downloadManager->removeFromCurl(msg->easy_handle);
    192204        }
    193205
     
    212224{
    213225    MutexLocker locker(m_mutex);
    214 
    215     if (m_curlHandle)
    216         curl_easy_cleanup(m_curlHandle);
    217226
    218227    if (m_url)
  • trunk/Source/WebCore/platform/network/curl/CurlDownload.h

    r151067 r152297  
    5959    bool runThread() const { return m_runThread; }
    6060    void setRunThread(bool runThread) { m_runThread = runThread; }
     61
     62    bool addToCurl(CURL* curlHandle);
     63    bool removeFromCurl(CURL* curlHandle);
    6164
    6265    static void downloadThread(void* data);
Note: See TracChangeset for help on using the changeset viewer.