@@ -9,124 +9,63 @@ These APIs are not implemented on musl
9
9
Upstream-Status: Pending
10
10
Signed-off-by: Khem Raj <
[email protected] >
11
11
---
12
- net/dns/dns_config_service_posix.cc | 30 +++++++++++++++++++++++++++++
13
- net/dns/dns_reloader.cc | 30 +++++++++++++++++++++++++++++
14
- 2 files changed, 60 insertions(+)
15
-
16
- --- a/net/dns/dns_config_service_posix.cc
17
- +++ b/net/dns/dns_config_service_posix.cc
18
- @@ -32,6 +32,36 @@
19
- #include "net/dns/dns_config_watcher_mac.h"
20
- #endif
21
-
22
- + #if !defined(__GLIBC__)
23
- + /***************************************************************************
24
- + * resolv_compat.h
25
- + *
26
- + * Mimick GLIBC's res_ninit() and res_nclose() for musl libc
27
- + * Note: res_init() is actually deprecated according to
28
- + * http://docs.oracle.com/cd/E36784_01/html/E36875/res-nclose-3resolv.html
29
- + **************************************************************************/
30
- + #include <string.h>
31
- +
32
- + static inline int res_ninit(res_state statp)
33
- + {
34
- + int rc = res_init();
35
- + if (statp != &_res) {
36
- + memcpy(statp, &_res, sizeof(*statp));
37
- + }
38
- + return rc;
39
- + }
40
- +
41
- + static inline int res_nclose(res_state statp)
42
- + {
43
- + if (!statp)
44
- + return -1;
45
- + if (statp != &_res) {
46
- + memset(statp, 0, sizeof(*statp));
47
- + }
48
- + return 0;
49
- + }
50
- + #endif
51
- +
52
- namespace net {
53
-
54
- namespace internal {
55
12
--- a/net/dns/dns_reloader.cc
56
13
+++ b/net/dns/dns_reloader.cc
57
- @@ -17,6 +17,36 @@
58
- #include "base/threading/thread_local.h"
59
- #include "net/base/network_change_notifier.h"
14
+ @@ -4,8 +4,7 @@
15
+
16
+ #include "net/dns/dns_reloader.h"
17
+
18
+ - #if defined(OS_POSIX) && !defined(OS_APPLE) && !defined(OS_OPENBSD) && \
19
+ - !defined(OS_ANDROID) && !defined(OS_FUCHSIA)
20
+ + #if defined(__GLIBC__)
60
21
61
- + #if !defined(__GLIBC__)
62
- + /***************************************************************************
63
- + * resolv_compat.h
64
- + *
65
- + * Mimick GLIBC's res_ninit() and res_nclose() for musl libc
66
- + * Note: res_init() is actually deprecated according to
67
- + * http://docs.oracle.com/cd/E36784_01/html/E36875/res-nclose-3resolv.html
68
- + **************************************************************************/
69
- + #include <string.h>
70
- +
71
- + static inline int res_ninit(res_state statp)
72
- + {
73
- + int rc = res_init();
74
- + if (statp != &_res) {
75
- + memcpy(statp, &_res, sizeof(*statp));
76
- + }
77
- + return rc;
78
- + }
79
- +
80
- + static inline int res_nclose(res_state statp)
81
- + {
82
- + if (!statp)
83
- + return -1;
84
- + if (statp != &_res) {
85
- + memset(statp, 0, sizeof(*statp));
86
- + }
87
- + return 0;
88
- + }
89
- + #endif
90
- +
91
- namespace net {
22
+ #include <resolv.h>
92
23
93
- namespace {
24
+ --- a/net/dns/host_resolver_manager.cc
25
+ +++ b/net/dns/host_resolver_manager.cc
26
+ @@ -2536,8 +2536,7 @@ HostResolverManager::HostResolverManager
27
+ NetworkChangeNotifier::AddConnectionTypeObserver(this);
28
+ if (system_dns_config_notifier_)
29
+ system_dns_config_notifier_->AddObserver(this);
30
+ - #if defined(OS_POSIX) && !defined(OS_APPLE) && !defined(OS_OPENBSD) && \
31
+ - !defined(OS_ANDROID)
32
+ + #if defined(__GLIBC__)
33
+ EnsureDnsReloaderInit();
34
+ #endif
35
+
36
+ --- a/net/dns/host_resolver_proc.cc
37
+ +++ b/net/dns/host_resolver_proc.cc
38
+ @@ -176,8 +176,7 @@ int SystemHostResolverCall(const std::st
39
+ base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
40
+ base::BlockingType::WILL_BLOCK);
41
+
42
+ - #if defined(OS_POSIX) && !defined(OS_APPLE) && !defined(OS_OPENBSD) && \
43
+ - !defined(OS_ANDROID) && !defined(OS_FUCHSIA)
44
+ + #if defined(__GLIBC__)
45
+ DnsReloaderMaybeReload();
46
+ #endif
47
+ absl::optional<AddressInfo> ai;
94
48
--- a/net/dns/dns_config_service_linux.cc
95
49
+++ b/net/dns/dns_config_service_linux.cc
96
- @@ -35,6 +35,36 @@
97
- #include "net/dns/serial_worker.h"
98
- #include "third_party/abseil-cpp/absl/types/optional.h"
50
+ @@ -486,20 +486,11 @@ class DnsConfigServiceLinux::ConfigReade
51
+
52
+ std::unique_ptr<struct __res_state>
53
+ DnsConfigServiceLinux::ResolvReader::GetResState() {
54
+ - auto res = std::make_unique<struct __res_state>();
55
+ - memset(res.get(), 0, sizeof(struct __res_state));
56
+ -
57
+ - if (res_ninit(res.get()) != 0) {
58
+ - CloseResState(res.get());
59
+ - return nullptr;
60
+ - }
61
+ -
62
+ - return res;
63
+ + return nullptr;
64
+ }
99
65
100
- + #if !defined(__GLIBC__)
101
- + /***************************************************************************
102
- + * resolv_compat.h
103
- + *
104
- + * Mimick GLIBC's res_ninit() and res_nclose() for musl libc
105
- + * Note: res_init() is actually deprecated according to
106
- + * http://docs.oracle.com/cd/E36784_01/html/E36875/res-nclose-3resolv.html
107
- + **************************************************************************/
108
- + #include <string.h>
109
- +
110
- + static inline int res_ninit(res_state statp)
111
- + {
112
- + int rc = res_init();
113
- + if (statp != &_res) {
114
- + memcpy(statp, &_res, sizeof(*statp));
115
- + }
116
- + return rc;
117
- + }
118
- +
119
- + static inline int res_nclose(res_state statp)
120
- + {
121
- + if (!statp)
122
- + return -1;
123
- + if (statp != &_res) {
124
- + memset(statp, 0, sizeof(*statp));
125
- + }
126
- + return 0;
127
- + }
128
- + #endif
129
- +
130
- namespace net {
66
+ void DnsConfigServiceLinux::ResolvReader::CloseResState(
67
+ struct __res_state* res) {
68
+ - res_nclose(res);
69
+ }
131
70
132
- namespace internal {
71
+ DnsConfigServiceLinux::DnsConfigServiceLinux()
0 commit comments