Avoid keeping sending queries to an invalid nameserver

When a nameserver is known to be not workable due to wrong setup,
e.g. invalid address or network unreachable, it should be considered
unusable, just like what the code does for a nameserver which always
times out.

This change is beneficial to:
  [1] Fix the bug which the code can never mark all of the
      nameservers as unusable in some edge cases.
  [2] Decrease the noise of internal_error in the metrics.

Bug: 144828038
Test: cd packages/modules/DnsResolver && atest
Change-Id: Id84c49690a7ae1dbd209f9f7751120052efd6c13
diff --git a/res_stats.cpp b/res_stats.cpp
index 36dde6b..f3b79bb 100644
--- a/res_stats.cpp
+++ b/res_stats.cpp
@@ -118,11 +118,11 @@
     android_net_res_stats_aggregate(stats, &successes, &errors, &timeouts, &internal_errors,
                                     &rtt_avg, &last_sample_time);
     if (successes >= 0 && errors >= 0 && timeouts >= 0) {
-        int total = successes + errors + timeouts;
+        int total = successes + errors + timeouts + internal_errors;
         LOG(INFO) << __func__ << ": NS stats: S " << successes << " + E " << errors << " + T "
                   << timeouts << " + I " << internal_errors << " = " << total
                   << ", rtt = " << rtt_avg << ", min_samples = " << unsigned(params->min_samples);
-        if (total >= params->min_samples && (errors > 0 || timeouts > 0)) {
+        if (total >= params->min_samples) {
             int success_rate = successes * 100 / total;
             LOG(INFO) << __func__ << ": success rate " << success_rate;
             if (success_rate < params->success_threshold) {