mirror of
https://github.com/klzgrad/naiveproxy.git
synced 2024-12-01 01:36:09 +03:00
dns: Support Musl
This commit is contained in:
parent
2585c28901
commit
e66193f527
@ -151,7 +151,7 @@ ConfigParsePosixResult ReadDnsConfig(DnsConfig* dns_config) {
|
|||||||
#if !defined(OS_ANDROID)
|
#if !defined(OS_ANDROID)
|
||||||
ConfigParsePosixResult result;
|
ConfigParsePosixResult result;
|
||||||
// TODO(fuchsia): Use res_ninit() when it's implemented on Fuchsia.
|
// TODO(fuchsia): Use res_ninit() when it's implemented on Fuchsia.
|
||||||
#if defined(OS_OPENBSD) || defined(OS_FUCHSIA)
|
#if defined(OS_OPENBSD) || defined(OS_FUCHSIA) || defined(__UCLIBC__)
|
||||||
// Note: res_ninit in glibc always returns 0 and sets RES_INIT.
|
// Note: res_ninit in glibc always returns 0 and sets RES_INIT.
|
||||||
// res_init behaves the same way.
|
// res_init behaves the same way.
|
||||||
memset(&_res, 0, sizeof(_res));
|
memset(&_res, 0, sizeof(_res));
|
||||||
|
@ -60,20 +60,32 @@ class DnsReloader : public NetworkChangeNotifier::DNSObserver {
|
|||||||
if (!reload_state) {
|
if (!reload_state) {
|
||||||
auto new_reload_state = std::make_unique<ReloadState>();
|
auto new_reload_state = std::make_unique<ReloadState>();
|
||||||
new_reload_state->resolver_generation = resolver_generation_;
|
new_reload_state->resolver_generation = resolver_generation_;
|
||||||
|
#ifndef __UCLIBC__
|
||||||
res_ninit(&_res);
|
res_ninit(&_res);
|
||||||
|
#else
|
||||||
|
res_init();
|
||||||
|
#endif
|
||||||
tls_reload_state_.Set(std::move(new_reload_state));
|
tls_reload_state_.Set(std::move(new_reload_state));
|
||||||
} else if (reload_state->resolver_generation != resolver_generation_) {
|
} else if (reload_state->resolver_generation != resolver_generation_) {
|
||||||
reload_state->resolver_generation = resolver_generation_;
|
reload_state->resolver_generation = resolver_generation_;
|
||||||
// It is safe to call res_nclose here since we know res_ninit will have
|
// It is safe to call res_nclose here since we know res_ninit will have
|
||||||
// been called above.
|
// been called above.
|
||||||
|
#ifndef __UCLIBC__
|
||||||
res_nclose(&_res);
|
res_nclose(&_res);
|
||||||
res_ninit(&_res);
|
res_ninit(&_res);
|
||||||
|
#else
|
||||||
|
res_init();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ReloadState {
|
struct ReloadState {
|
||||||
~ReloadState() { res_nclose(&_res); }
|
~ReloadState() {
|
||||||
|
#ifndef __UCLIBC__
|
||||||
|
res_nclose(&_res);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int resolver_generation;
|
int resolver_generation;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user