2007-11-21 Alp Toker <alp@atoker.com>
authoralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Nov 2007 03:28:14 +0000 (03:28 +0000)
committeralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Nov 2007 03:28:14 +0000 (03:28 +0000)
        Reviewed by Mark Rowe.

        http://bugs.webkit.org/show_bug.cgi?id=16071
        Curl backend handles EINTR incorrectly

        Defer timers during select() to avoid interruption by timer signals.

        * platform/network/curl/ResourceHandleManager.cpp:
        (WebCore::ResourceHandleManager::downloadTimerCallback):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27948 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/network/curl/ResourceHandleManager.cpp

index b7b551b65c003d7d96b870a38842997674f50439..12fbe2398874fee15c070b863110db25ad85463e 100644 (file)
@@ -1,3 +1,15 @@
+2007-11-21  Alp Toker  <alp@atoker.com>
+
+        Reviewed by Mark Rowe.
+
+        http://bugs.webkit.org/show_bug.cgi?id=16071
+        Curl backend handles EINTR incorrectly
+
+        Defer timers during select() to avoid interruption by timer signals.
+
+        * platform/network/curl/ResourceHandleManager.cpp:
+        (WebCore::ResourceHandleManager::downloadTimerCallback):
+
 2007-11-21  Mark Rowe  <mrowe@apple.com>
 
         Reviewed by Tim Hatcher.
index dde0aab4993fcbc4fe06a346aaf13136452774fc..a6edc0edaa36c64c2a400fce81d7219fb8cae66e 100644 (file)
@@ -186,7 +186,10 @@ void ResourceHandleManager::downloadTimerCallback(Timer<ResourceHandleManager>*
     timeout.tv_sec = 0;
     timeout.tv_usec = selectTimeoutMS * 1000;       // select waits microseconds
 
+    // Temporarily disable timers since signals may interrupt select(), raising EINTR errors on some platforms
+    setDeferringTimers(true);
     int rc = ::select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
+    setDeferringTimers(false);
 
     if (-1 == rc) {
 #ifndef NDEBUG
@@ -196,10 +199,7 @@ void ResourceHandleManager::downloadTimerCallback(Timer<ResourceHandleManager>*
     }
 
     int runningHandles = 0;
-    CURLMcode curlCode = CURLM_CALL_MULTI_PERFORM;
-    while (CURLM_CALL_MULTI_PERFORM == curlCode) {
-        curlCode = curl_multi_perform(m_curlMultiHandle, &runningHandles);
-    }
+    while (curl_multi_perform(m_curlMultiHandle, &runningHandles) == CURLM_CALL_MULTI_PERFORM) { }
 
     // check the curl messages indicating completed transfers
     // and free their resources