Bug 1231552 - Back out 2 changesets (bug 1121800, bug 1214200) r=mcmanus a=ritu
authorWes Kocher <wkocher@mozilla.com>
Wed, 23 Dec 2015 12:31:22 -0800
changeset 305877 9d310a41f8c220b00b0b781a88f6abe974a3eca2
parent 305876 bac789f5d52ceaa186fffdc2116dac424be4d51a
child 305878 19b9d400cf8ef12e060fa87f13f8da6257b125fb
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus, ritu
bugs1231552, 1121800, 1214200
milestone44.0
Bug 1231552 - Back out 2 changesets (bug 1121800, bug 1214200) r=mcmanus a=ritu Backed out changeset a62a3c113e40 (bug 1214200) Backed out changeset 13db8516d365 (bug 1121800)
netwerk/base/nsProtocolProxyService.cpp
--- a/netwerk/base/nsProtocolProxyService.cpp
+++ b/netwerk/base/nsProtocolProxyService.cpp
@@ -1400,19 +1400,21 @@ nsProtocolProxyService::NewProxyInfo(con
 }
 
 NS_IMETHODIMP
 nsProtocolProxyService::GetFailoverForProxy(nsIProxyInfo  *aProxy,
                                             nsIURI        *aURI,
                                             nsresult       aStatus,
                                             nsIProxyInfo **aResult)
 {
-    if (mProxyConfig == PROXYCONFIG_DIRECT) {
+    // We only support failover when a PAC file is configured, either
+    // directly or via system settings
+    if (mProxyConfig != PROXYCONFIG_PAC && mProxyConfig != PROXYCONFIG_WPAD &&
+        mProxyConfig != PROXYCONFIG_SYSTEM)
         return NS_ERROR_NOT_AVAILABLE;
-    }
 
     // Verify that |aProxy| is one of our nsProxyInfo objects.
     nsCOMPtr<nsProxyInfo> pi = do_QueryInterface(aProxy);
     NS_ENSURE_ARG(pi);
     // OK, the QI checked out.  We can proceed.
 
     // Remember that this proxy is down.
     DisableProxy(pi);
@@ -1998,51 +2000,62 @@ nsProtocolProxyService::PruneProxyInfo(c
                 last = iter;
                 iter = iter->mNext;
             }
         }
         if (!head)
             return;
     }
 
-    // Now, scan to the next proxy not disabled. If all proxies are disabled,
-    // return blank list to enforce a DIRECT rule.
+    // Now, scan to see if all remaining proxies are disabled.  If so, then
+    // we'll just bail and return them all.  Otherwise, we'll go and prune the
+    // disabled ones.
 
     bool allDisabled = true;
+
     nsProxyInfo *iter;
-
-    // remove any disabled proxies.
-    nsProxyInfo *last = nullptr;
-    for (iter = head; iter; ) {
-        if (IsProxyDisabled(iter)) {
-            // reject!
-            nsProxyInfo *reject = iter;
-
-            iter = iter->mNext;
-            if (last)
-                last->mNext = iter;
-            else
-                head = iter;
-
-            reject->mNext = nullptr;
-            NS_RELEASE(reject);
-            continue;
+    for (iter = head; iter; iter = iter->mNext) {
+        if (!IsProxyDisabled(iter)) {
+            allDisabled = false;
+            break;
         }
-
-        allDisabled = false;
-        EnableProxy(iter);
-
-        last = iter;
-        iter = iter->mNext;
     }
 
-    if (allDisabled) {
-        LOG(("All proxies are disabled, try a DIRECT rule!"));
-        *list = nullptr;
-        return;
+    if (allDisabled)
+        LOG(("All proxies are disabled, so trying all again"));
+    else {
+        // remove any disabled proxies.
+        nsProxyInfo *last = nullptr;
+        for (iter = head; iter; ) {
+            if (IsProxyDisabled(iter)) {
+                // reject!
+                nsProxyInfo *reject = iter;
+
+                iter = iter->mNext;
+                if (last)
+                    last->mNext = iter;
+                else
+                    head = iter;
+
+                reject->mNext = nullptr;
+                NS_RELEASE(reject);
+                continue;
+            }
+
+            // since we are about to use this proxy, make sure it is not on
+            // the disabled proxy list.  we'll add it back to that list if
+            // we have to (in GetFailoverForProxy).
+            //
+            // XXX(darin): It might be better to do this as a final pass.
+            //
+            EnableProxy(iter);
+
+            last = iter;
+            iter = iter->mNext;
+        }
     }
 
     // if only DIRECT was specified then return no proxy info, and we're done.
     if (head && !head->mNext && head->mType == kProxyType_DIRECT)
         NS_RELEASE(head);
 
     *list = head;  // Transfer ownership
 }