new/yocto/meta-browser/meta-chromium/recipes-browser/chromium/files/musl/0009-provide-res_ninit-and-nclose-APIs-on-non-glibc-linux.patch
2025-05-10 21:58:58 +08:00

88 lines
3.0 KiB
Diff

From 38aef4b65a03ea13c2a9bdf02ce7987da83cfbe3 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 13 Feb 2019 09:51:14 -0800
Subject: [PATCH] provide res_ninit and nclose APIs on non-glibc linux
platforms
These APIs are not implemented on musl
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
net/dns/dns_reloader.cc | 3 +--
net/dns/host_resolver_system_task.cc | 6 ++----
net/dns/public/scoped_res_state.cc | 14 +++-----------
3 files changed, 6 insertions(+), 17 deletions(-)
diff --git a/net/dns/dns_reloader.cc b/net/dns/dns_reloader.cc
index bfd2de11f9..fef7569c13 100644
--- a/net/dns/dns_reloader.cc
+++ b/net/dns/dns_reloader.cc
@@ -6,8 +6,7 @@
#include "build/build_config.h"
-#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_OPENBSD) && \
- !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_FUCHSIA)
+#if defined(__GLIBC__)
#include <resolv.h>
diff --git a/net/dns/host_resolver_system_task.cc b/net/dns/host_resolver_system_task.cc
index c067da3e85..010719971c 100644
--- a/net/dns/host_resolver_system_task.cc
+++ b/net/dns/host_resolver_system_task.cc
@@ -351,8 +351,7 @@ void HostResolverSystemTask::OnLookupComplete(const uint32_t attempt_number,
}
void EnsureSystemHostResolverCallReady() {
-#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_OPENBSD) && \
- !BUILDFLAG(IS_ANDROID)
+#if defined(__GLIBC__)
EnsureDnsReloaderInit();
#elif BUILDFLAG(IS_WIN)
EnsureWinsockInit();
@@ -437,8 +436,7 @@ int SystemHostResolverCall(const std::string& host,
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
base::BlockingType::WILL_BLOCK);
-#if BUILDFLAG(IS_POSIX) && \
- !(BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_OPENBSD) || BUILDFLAG(IS_ANDROID))
+#if defined(__GLIBC__)
DnsReloaderMaybeReload();
#endif
auto [ai, err, os_error] = AddressInfo::Get(host, hints, nullptr, network);
diff --git a/net/dns/public/scoped_res_state.cc b/net/dns/public/scoped_res_state.cc
index 2743697bf6..36dc8adbf5 100644
--- a/net/dns/public/scoped_res_state.cc
+++ b/net/dns/public/scoped_res_state.cc
@@ -13,7 +13,7 @@
namespace net {
ScopedResState::ScopedResState() {
-#if BUILDFLAG(IS_OPENBSD) || BUILDFLAG(IS_FUCHSIA)
+#if BUILDFLAG(IS_OPENBSD) || BUILDFLAG(IS_FUCHSIA) || defined(_GNU_SOURCE)
// Note: res_ninit in glibc always returns 0 and sets RES_INIT.
// res_init behaves the same way.
memset(&_res, 0, sizeof(_res));
@@ -25,16 +25,8 @@ ScopedResState::ScopedResState() {
}
ScopedResState::~ScopedResState() {
-#if !BUILDFLAG(IS_OPENBSD) && !BUILDFLAG(IS_FUCHSIA)
-
- // Prefer res_ndestroy where available.
-#if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_FREEBSD)
- res_ndestroy(&res_);
-#else
- res_nclose(&res_);
-#endif // BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_FREEBSD)
-
-#endif // !BUILDFLAG(IS_OPENBSD) && !BUILDFLAG(IS_FUCHSIA)
+ // musl res_init() doesn't actually do anything
+ // no destruction is necessary as no memory has been allocated
}
bool ScopedResState::IsValid() const {