[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

ap at apple.com ap at apple.com
Wed Dec 22 18:43:40 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 6d8dfe4b6a785403038df4aac33fef9cf09673e9
Author: ap at apple.com <ap at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 16 17:54:22 2010 +0000

            Reviewed by Darin Adler.
    
            https://bugs.webkit.org/show_bug.cgi?id=50996
            <rdar://problem/8086718> Consider disabling DNS prefetch when proxy is used
    
            No new tests, cannot test DNS.
    
            * platform/network/cf/DNSCFNet.cpp:
            (WebCore::proxyIsEnabledInSystemPreferences): Check if accessing example.com is going to use
            a proxy. This is only an estimate - even with a proxy is configured in system preferences, an
            actual request can go directly to the host if a PAC script says so.
            (WebCore::DNSResolveQueue::add): Check if proxy is enabled when sending immediate requests.
            (WebCore::DNSResolveQueue::fired): Ditto when sending queued ones.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74197 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 55983a3..3b66fb4 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,19 @@
+2010-12-15  Alexey Proskuryakov  <ap at apple.com>
+
+        Reviewed by Darin Adler.
+
+        https://bugs.webkit.org/show_bug.cgi?id=50996
+        <rdar://problem/8086718> Consider disabling DNS prefetch when proxy is used
+
+        No new tests, cannot test DNS.
+
+        * platform/network/cf/DNSCFNet.cpp:
+        (WebCore::proxyIsEnabledInSystemPreferences): Check if accessing example.com is going to use
+        a proxy. This is only an estimate - even with a proxy is configured in system preferences, an
+        actual request can go directly to the host if a PAC script says so.
+        (WebCore::DNSResolveQueue::add): Check if proxy is enabled when sending immediate requests.
+        (WebCore::DNSResolveQueue::fired): Ditto when sending queued ones.
+
 2010-12-16  Yury Semikhatsky  <yurys at chromium.org>
 
         Reviewed by Pavel Feldman.
diff --git a/WebCore/platform/network/cf/DNSCFNet.cpp b/WebCore/platform/network/cf/DNSCFNet.cpp
index fbceb7d..166abbf 100644
--- a/WebCore/platform/network/cf/DNSCFNet.cpp
+++ b/WebCore/platform/network/cf/DNSCFNet.cpp
@@ -27,6 +27,7 @@
 #include "config.h"
 #include "DNS.h"
 
+#include "KURL.h"
 #include "Timer.h"
 #include <wtf/HashSet.h>
 #include <wtf/RetainPtr.h>
@@ -37,6 +38,10 @@
 #include "LoaderRunLoopCF.h"
 #endif
 
+#if defined(BUILDING_ON_LEOPARD)
+#include <SystemConfiguration/SystemConfiguration.h>
+#endif
+
 #ifdef BUILDING_ON_TIGER
 // This function is available on Tiger, but not declared in the CFRunLoop.h header on Tiger.
 extern "C" CFRunLoopRef CFRunLoopGetMain();
@@ -62,6 +67,37 @@ const int maxRequestsToQueue = 64;
 // If there were queued names that couldn't be sent simultaneously, check the state of resolvers after this delay.
 const double retryResolvingInSeconds = 0.1;
 
+static bool proxyIsEnabledInSystemPreferences()
+{
+    // Don't do DNS prefetch if proxies are involved. For many proxy types, the user agent is never exposed
+    // to the IP address during normal operation. Querying an internal DNS server may not help performance,
+    // as it doesn't necessarily look up the actual external IP. Also, if DNS returns a fake internal address,
+    // local caches may keep it even after re-connecting to another network.
+
+#if !defined(BUILDING_ON_LEOPARD)
+    RetainPtr<CFDictionaryRef> proxySettings(AdoptCF, CFNetworkCopySystemProxySettings());
+#else
+    RetainPtr<CFDictionaryRef> proxySettings(AdoptCF, SCDynamicStoreCopyProxies(0));
+#endif
+    if (!proxySettings)
+        return false;
+
+    static CFURLRef httpCFURL = KURL(ParsedURLString, "http://example.com/").createCFURL();
+    static CFURLRef httpsCFURL = KURL(ParsedURLString, "https://example.com/").createCFURL();
+
+    RetainPtr<CFArrayRef> httpProxyArray(AdoptCF, CFNetworkCopyProxiesForURL(httpCFURL, proxySettings.get()));
+    RetainPtr<CFArrayRef> httpsProxyArray(AdoptCF, CFNetworkCopyProxiesForURL(httpsCFURL, proxySettings.get()));
+
+    CFIndex httpProxyCount = CFArrayGetCount(httpProxyArray.get());
+    CFIndex httpsProxyCount = CFArrayGetCount(httpsProxyArray.get());
+    if (httpProxyCount == 1 && CFEqual(CFDictionaryGetValue(static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(httpProxyArray.get(), 0)), kCFProxyTypeKey), kCFProxyTypeNone))
+        httpProxyCount = 0;
+    if (httpsProxyCount == 1 && CFEqual(CFDictionaryGetValue(static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(httpsProxyArray.get(), 0)), kCFProxyTypeKey), kCFProxyTypeNone))
+        httpsProxyCount = 0;
+
+    return httpProxyCount || httpsProxyCount;
+}
+
 class DNSResolveQueue : public TimerBase {
 public:
     static DNSResolveQueue& shared();
@@ -92,6 +128,9 @@ void DNSResolveQueue::add(const String& name)
 {
     // If there are no names queued, and few enough are in flight, resolve immediately (the mouse may be over a link).
     if (!m_names.size()) {
+        if (proxyIsEnabledInSystemPreferences())
+            return;
+
         if (atomicIncrement(&m_requestsInFlight) <= namesToResolveImmediately) {
             resolve(name);
             return;
@@ -115,6 +154,11 @@ void DNSResolveQueue::decrementRequestCount()
 
 void DNSResolveQueue::fired()
 {
+    if (proxyIsEnabledInSystemPreferences()) {
+        m_names.clear();
+        return;
+    }
+
     int requestsAllowed = maxSimultaneousRequests - m_requestsInFlight;
 
     for (; !m_names.isEmpty() && requestsAllowed > 0; --requestsAllowed) {

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list