Backout bug 1190502 for leaks
authorEhsan Akhgari <ehsan@mozilla.com>
Sat, 08 Aug 2015 18:13:02 -0400
changeset 288625 bbc6b3d81906c5eab30f27ee14c65128dbb60bea
parent 288624 d10584967bb9d020aeecaa212241003d4144e959
child 288626 7a7febd0dcbe437086acdeee2225f3fe9209e4d1
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1190502
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backout bug 1190502 for leaks
netwerk/dns/nsHostResolver.cpp
netwerk/test/unit/test_dns_disable_ipv4.js
netwerk/test/unit/test_dns_disable_ipv6.js
netwerk/test/unit/xpcshell.ini
--- a/netwerk/dns/nsHostResolver.cpp
+++ b/netwerk/dns/nsHostResolver.cpp
@@ -1398,24 +1398,29 @@ nsHostResolver::ThreadFunc(void *arg)
 
         TimeStamp startTime = TimeStamp::Now();
 #if TTL_AVAILABLE
         bool getTtl = rec->mGetTtl;
 #else
         bool getTtl = false;
 #endif
 
-        nsresult status = GetAddrInfo(rec->host, rec->af, rec->flags, rec->netInterface,
+        // We need to remove IPv4 records manually
+        // because PR_GetAddrInfoByName doesn't support PR_AF_INET6.
+        bool disableIPv4 = rec->af == PR_AF_INET6;
+        uint16_t af = disableIPv4 ? PR_AF_UNSPEC : rec->af;
+        nsresult status = GetAddrInfo(rec->host, af, rec->flags, rec->netInterface,
                                       &ai, getTtl);
 #if defined(RES_RETRY_ON_FAILURE)
         if (NS_FAILED(status) && rs.Reset()) {
-            status = GetAddrInfo(rec->host, rec->af, rec->flags, rec->netInterface, &ai,
+            status = GetAddrInfo(rec->host, af, rec->flags, rec->netInterface, &ai,
                                  getTtl);
         }
 #endif
+
         TimeDuration elapsed = TimeStamp::Now() - startTime;
         uint32_t millis = static_cast<uint32_t>(elapsed.ToMilliseconds());
 
         if (NS_SUCCEEDED(status)) {
             Telemetry::ID histogramID;
             if (!rec->addr_info_gencnt) {
                 // Time for initial lookup.
                 histogramID = Telemetry::DNS_LOOKUP_TIME;
deleted file mode 100644
--- a/netwerk/test/unit/test_dns_disable_ipv4.js
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// Tests that calling asyncResolve with the RESOLVE_DISABLE_IPV4 flag doesn't
-// return any IPv4 addresses.
-//
-
-var dns = Cc["@mozilla.org/network/dns-service;1"].getService(Ci.nsIDNSService);
-var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
-
-var listener = {
-  onLookupComplete: function(inRequest, inRecord, inStatus) {
-    if (inStatus != Cr.NS_OK) {
-      do_check_eq(inStatus, Cr.NS_ERROR_UNKNOWN_HOST);
-      do_test_finished();
-      return;
-    }
-
-    while (true) {
-      try {
-        var answer = inRecord.getNextAddrAsString();
-        // If there is an answer it should be an IPv6  address
-        dump(answer);
-        do_check_true(answer.indexOf(':') != -1);
-      } catch (e) {
-        break;
-      }
-    }
-    do_test_finished();
-  }
-};
-
-function run_test() {
-  do_test_pending();
-  try {
-    dns.asyncResolve("example.org", Ci.nsIDNSService.RESOLVE_DISABLE_IPV4, listener, null);
-  } catch (e) {
-    dump(e);
-    do_check_true(false);
-    do_test_finished();
-  }
-}
deleted file mode 100644
--- a/netwerk/test/unit/test_dns_disable_ipv6.js
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// Tests that calling asyncResolve with the RESOLVE_DISABLE_IPV6 flag doesn't
-// return any IPv6 addresses.
-//
-
-var dns = Cc["@mozilla.org/network/dns-service;1"].getService(Ci.nsIDNSService);
-var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
-
-var listener = {
-  onLookupComplete: function(inRequest, inRecord, inStatus) {
-    if (inStatus != Cr.NS_OK) {
-      do_check_eq(inStatus, Cr.NS_ERROR_UNKNOWN_HOST);
-      do_test_finished();
-      return;
-    }
-
-    while (true) {
-      try {
-        var answer = inRecord.getNextAddrAsString();
-        // If there is an answer it should be an IPv4  address
-        dump(answer);
-        do_check_true(answer.indexOf(':') == -1);
-        do_check_true(answer.indexOf('.') != -1);
-      } catch (e) {
-        break;
-      }
-    }
-    do_test_finished();
-  }
-};
-
-function run_test() {
-  do_test_pending();
-  try {
-    dns.asyncResolve("example.com", Ci.nsIDNSService.RESOLVE_DISABLE_IPV6, listener, null);
-  } catch (e) {
-    dump(e);
-    do_check_true(false);
-    do_test_finished();
-  }
-}
--- a/netwerk/test/unit/xpcshell.ini
+++ b/netwerk/test/unit/xpcshell.ini
@@ -319,10 +319,8 @@ skip-if = os != "win"
 # The local cert service used by this test is not currently shipped on Android
 skip-if = os == "android"
 [test_1073747.js]
 [test_multipart_streamconv_application_package.js]
 [test_safeoutputstream_append.js]
 [test_packaged_app_service.js]
 [test_suspend_channel_before_connect.js]
 [test_inhibit_caching.js]
-[test_dns_disable_ipv4.js]
-[test_dns_disable_ipv6.js]