Title: [152297] trunk/Source/WebCore
- Revision
- 152297
- Author
- [email protected]
- Date
- 2013-07-02 09:26:03 -0700 (Tue, 02 Jul 2013)
Log Message
[Curl] Crash after download.
https://bugs.webkit.org/show_bug.cgi?id=118303
Patch by [email protected] <[email protected]> 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.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (152296 => 152297)
--- trunk/Source/WebCore/ChangeLog 2013-07-02 16:21:36 UTC (rev 152296)
+++ trunk/Source/WebCore/ChangeLog 2013-07-02 16:26:03 UTC (rev 152297)
@@ -1,3 +1,20 @@
+2013-07-02 [email protected] <[email protected]>
+
+ [Curl] Crash after download.
+ https://bugs.webkit.org/show_bug.cgi?id=118303
+
+ 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.
+
2013-07-02 Radu Stavila <[email protected]>
[CSSRegions] No other SVG elements except the SVGRoot must have RegionInfo objects attached
Modified: trunk/Source/WebCore/platform/network/curl/CurlDownload.cpp (152296 => 152297)
--- trunk/Source/WebCore/platform/network/curl/CurlDownload.cpp 2013-07-02 16:21:36 UTC (rev 152296)
+++ trunk/Source/WebCore/platform/network/curl/CurlDownload.cpp 2013-07-02 16:26:03 UTC (rev 152297)
@@ -121,22 +121,34 @@
// Add pending curl easy handles to multi list
int size = m_pendingHandleList.size();
for (int i = 0; i < size; i++) {
- CURLMcode retval = curl_multi_add_handle(m_curlMultiHandle, m_pendingHandleList[0]);
-
- if (retval == CURLM_OK)
+ if (addToCurl(m_pendingHandleList[0]))
m_pendingHandleList.remove(0);
}
// Remove curl easy handles from multi list
size = m_removedHandleList.size();
for (int i = 0; i < size; i++) {
- CURLMcode retval = curl_multi_remove_handle(m_curlMultiHandle, m_removedHandleList[0]);
-
- if (retval == CURLM_OK)
+ if (removeFromCurl(m_removedHandleList[0]))
m_removedHandleList.remove(0);
}
}
+bool CurlDownloadManager::addToCurl(CURL* curlHandle)
+{
+ CURLMcode retval = curl_multi_add_handle(m_curlMultiHandle, curlHandle);
+ return retval == CURLM_OK;
+}
+
+bool CurlDownloadManager::removeFromCurl(CURL* curlHandle)
+{
+ CURLMcode retval = curl_multi_remove_handle(m_curlMultiHandle, curlHandle);
+ if (retval == CURLM_OK) {
+ curl_easy_cleanup(curlHandle);
+ return true;
+ }
+ return false;
+}
+
void CurlDownloadManager::downloadThread(void* data)
{
CurlDownloadManager* downloadManager = reinterpret_cast<CurlDownloadManager*>(data);
@@ -188,7 +200,7 @@
else
callOnMainThread<CurlDownload*, CurlDownload*>(CurlDownload::downloadFailedCallback, download);
- curl_multi_remove_handle(downloadManager->getMultiHandle(), msg->easy_handle);
+ downloadManager->removeFromCurl(msg->easy_handle);
}
downloadManager->stopThreadIfIdle();
@@ -212,9 +224,6 @@
{
MutexLocker locker(m_mutex);
- if (m_curlHandle)
- curl_easy_cleanup(m_curlHandle);
-
if (m_url)
fastFree(m_url);
Modified: trunk/Source/WebCore/platform/network/curl/CurlDownload.h (152296 => 152297)
--- trunk/Source/WebCore/platform/network/curl/CurlDownload.h 2013-07-02 16:21:36 UTC (rev 152296)
+++ trunk/Source/WebCore/platform/network/curl/CurlDownload.h 2013-07-02 16:26:03 UTC (rev 152297)
@@ -59,6 +59,9 @@
bool runThread() const { return m_runThread; }
void setRunThread(bool runThread) { m_runThread = runThread; }
+ bool addToCurl(CURL* curlHandle);
+ bool removeFromCurl(CURL* curlHandle);
+
static void downloadThread(void* data);
ThreadIdentifier m_threadId;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes