commit | e93d9ae12ae8df2eac9b1a06c98b6141b08a3fe3 | [log] [tgz] |
---|---|---|
author | Mike Yu <yumike@google.com> | Tue Aug 25 19:09:51 2020 +0800 |
committer | Mike Yu <yumike@google.com> | Sat Sep 26 19:18:44 2020 +0800 |
tree | f02c32b2f1fba07019da937e07eac2bb8cf65ebc | |
parent | 6bcde8897a67562932202b2b1d2720539e72963b [diff] |
Allow to do TLS handshake on DnsTlsSocket loop thread There are some performance concerns about running connection handshake on query threads (which are launched from DnsProxyListener): - Until a handshake running on a query thread finishes, other query threads get blocked from acquiring the lock, which is hard to implement timeout. - If the handshake fails, all of the waiting query threads can't know it. Then, one of the them will do another handshake which is likely to fail again. This change introduces a flag which moves connection handshake from query threads to DnsTlsSocket loop thread to address the concerns. - Before a handshake finishes, query threads are waiting their std::future result. This helps future implementation for query timeout. - If the handshake fails kMaxTries times, none of the waiting query threads does another handshake to the same DoT server again. They can either try next DoT server or falls back to Do53. Besides, with the flag enabled, DnsTlsSocket can be aware of shutdown request and instantly stop connection handshake if needed. Bug: 149445907 Test: cd packages/modules/DnsResolver set the flag on, ran atest rebooted, set the flag off, ran atest Change-Id: I6a0a4c962c9eaf78ca2796128018f7ba06897b16
This code uses LOG(X) for logging. Log levels are VERBOSE,DEBUG,INFO,WARNING and ERROR. The default setting is WARNING and logs relate to WARNING and ERROR will be shown. If you want to enable the DEBUG level logs, using following command. adb shell service call dnsresolver 10 i32 1 VERBOSE 0 DEBUG 1 INFO 2 WARNING 3 ERROR 4 Verbose resolver logs could contain PII -- do NOT enable in production builds.