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
Loading
Please register or sign in to comment