Improve resolver cache lock and thread synchronization

This change comprises:
1. replace pthread_mutex with std::mutex to realize RAII.
2. have a single condition variable to prevent race condition between
   threads.
3. add 'predicate' to avoid spurious awakenings.
4. add a parameter in GetResolverInfo API which enabling test cases to
   know if timeout happened among concurrent DNS queries. Also, dump it in
   bugreport.
5. verify if test case GetAddrInfoV6_concurrent,
   GetAddrInfoStressTest_Binder_100 and
   GetAddrInfoStressTest_Binder_100000 pass because of timeout on
   concurrent DNS queries.

Bug: 120794954
Test: runtests.sh pass
Test: run ResolverTest.GetAddrInfoV6_concurrent 100 times
Test: run ResolverTest.GetAddrInfoStressTest_Binder_100 100 times
Test: run ResolverTest.GetAddrInfoStressTest_Binder_100000 100 times
The test script:
----------------------------
for i in $(seq 1 100)
do
  adb shell resolv_integration_test --gtest_filter=ResolverTest.GetAddrInfoV6_concurrent
  adb shell resolv_integration_test --gtest_filter=ResolverTest.GetAddrInfoStressTest_Binder_100
  adb shell resolv_integration_test --gtest_filter=ResolverTest.GetAddrInfoStressTest_Binder_100000
done
exit 0

Change-Id: I4bdc394ba7ded7a6b7239f2d35b559a4262cb7b9
diff --git a/server/ResolverController.h b/server/ResolverController.h
index 4a104ed..6d8b741 100644
--- a/server/ResolverController.h
+++ b/server/ResolverController.h
@@ -46,8 +46,9 @@
     int clearDnsServers(unsigned netid);
 
     int getDnsInfo(unsigned netId, std::vector<std::string>* servers,
-            std::vector<std::string>* domains, __res_params* params,
-            std::vector<android::net::ResolverStats>* stats);
+                   std::vector<std::string>* domains, __res_params* params,
+                   std::vector<android::net::ResolverStats>* stats,
+                   std::vector<int32_t>* wait_for_pending_req_timeout_count);
 
     int getPrefix64(unsigned netId, netdutils::IPPrefix* prefix);
 
@@ -60,7 +61,8 @@
 
     int getResolverInfo(int32_t netId, std::vector<std::string>* servers,
                         std::vector<std::string>* domains, std::vector<std::string>* tlsServers,
-                        std::vector<int32_t>* params, std::vector<int32_t>* stats);
+                        std::vector<int32_t>* params, std::vector<int32_t>* stats,
+                        std::vector<int32_t>* wait_for_pending_req_timeout_count);
 
     void sendNat64PrefixEvent(const net::Dns64Configuration::Nat64PrefixInfo& args);