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