Explicitly allocate ResState on the call stack

Previously known as __res_state, res_state, res or even statp, the
ResState struct holds the context of a query in progress.

After a long series of preparatory patches, the thread-local storage
nonsense that's been plaguing this fine codebase for decades is finally
gone. Sayonara! ResState is now explicitly allocated on the stack at the
beginning of each query and passed down as a regular function argument.

To keep this patch reviewable, I threw in two compatibility typedefs for
the legacy names. We'll get rid of them in a separate mechanical patch.

Next steps:
 - Give ResState a regular constructor and, crucially, a real destructor
 - Move the definition to ResState.h, like it's a real class
 - Populate the nameservers immediately on construction
 - Switch to safe C++ data structures

Change-Id: I5c0b85da3ad9a55fa41dca6c87e57fe8f50c6abc
14 files changed
tree: f6157ae38bb36ca445fa9a8a48d5b40a9c8fc11e
  1. aidl/
  2. apex/
  3. binder/
  4. include/
  5. tests/
  6. .editorconfig
  7. Android.bp
  8. Dns64Configuration.cpp
  9. Dns64Configuration.h
  10. DnsProxyListener.cpp
  11. DnsProxyListener.h
  12. DnsResolver.cpp
  13. DnsResolver.h
  14. dnsresolver_binder_test.cpp
  15. DnsResolverService.cpp
  16. DnsResolverService.h
  17. DnsTlsDispatcher.cpp
  18. DnsTlsDispatcher.h
  19. DnsTlsQueryMap.cpp
  20. DnsTlsQueryMap.h
  21. DnsTlsServer.cpp
  22. DnsTlsServer.h
  23. DnsTlsSessionCache.cpp
  24. DnsTlsSessionCache.h
  25. DnsTlsSocket.cpp
  26. DnsTlsSocket.h
  27. DnsTlsSocketFactory.h
  28. DnsTlsTransport.cpp
  29. DnsTlsTransport.h
  30. getaddrinfo.cpp
  31. getaddrinfo.h
  32. gethnamaddr.cpp
  33. gethnamaddr.h
  34. hostent.h
  35. IDnsTlsSocket.h
  36. IDnsTlsSocketFactory.h
  37. IDnsTlsSocketObserver.h
  38. libnetd_resolv.map.txt
  39. LockedQueue.h
  40. NOTICE
  41. OWNERS
  42. PREUPLOAD.cfg
  43. PrivateDnsConfiguration.cpp
  44. PrivateDnsConfiguration.h
  45. README-DoT.md
  46. README.md
  47. res_cache.cpp
  48. res_comp.cpp
  49. res_debug.cpp
  50. res_debug.h
  51. res_init.cpp
  52. res_init.h
  53. res_mkquery.cpp
  54. res_query.cpp
  55. res_send.cpp
  56. res_send.h
  57. res_stats.cpp
  58. resolv_cache.h
  59. resolv_cache_unit_test.cpp
  60. resolv_integration_test.cpp
  61. resolv_private.h
  62. resolv_tls_unit_test.cpp
  63. resolv_unit_test.cpp
  64. ResolverController.cpp
  65. ResolverController.h
  66. ResolverEventReporter.cpp
  67. ResolverEventReporter.h
  68. ResolverStats.h
  69. sethostent.cpp
  70. stats.proto
  71. TEST_MAPPING
README.md

Logging

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.