deps: update c-ares to 1.29.0

PR-URL: https://github.com/nodejs/node/pull/53155
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
This commit is contained in:
Node.js GitHub Bot 2024-06-02 08:30:14 +03:00 committed by GitHub
parent 78a326e2eb
commit 41d90aaf62
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
107 changed files with 13339 additions and 11616 deletions

449
deps/cares/CHANGES vendored
View file

@ -1,5 +1,298 @@
Changelog for the c-ares project. Generated with git2changes.pl
Version 1.29.0 (22 May 2024)
GitHub (22 May 2024)
- [Brad House brought this change]
1.29.0 release prep (#762)
Brad House (22 May 2024)
- coverity: try to silence warning
- branch main
- clang-format
GitHub (22 May 2024)
- [Brad House brought this change]
Auto reload config on changes (requires EventThread) (#759)
Automatically detect configuration changes and reload. On systems which
provide notification mechanisms, use those, otherwise fallback to
polling. When a system configuration change is detected, it
asynchronously applies the configuration in order to ensure it is a
non-blocking operation for any queries which may still be being
processed.
On Windows, however, changes aren't detected if a user manually
sets/changes the DNS servers on an interface, it doesn't appear there is
any mechanism capable of this. We are relying on
`NotifyIpInterfaceChange()` for notifications.
Fixes Issue: #613
Fix By: Brad House (@bradh352)
- [David Hotham brought this change]
const is fine on ares__channel_[un]lock (#758)
at https://github.com/c-ares/c-ares/pull/601#issuecomment-1801935063 you
chose not to scatter `const` on the public interface because of the plan
- now realised - to add threading to c-ares, and in the expectation that
even read operations would need to lock the mutex.
But the threading implementation has a _pointer_ to a mutex inside the
ares channel and as I understand it, that means that it is just fine to
mark `ares__channel_lock` (and `ares__channel_unlock`) as taking a
`const` channel. It is the pointed-to mutex that is not constant, but C
does not propagate `const`-ness through pointers.
This PR sprinkles const where appropriate on public interfaces.
Fix By: David Hotham (@dimbleby)
Brad House (15 May 2024)
- remove accidentally committed in-development file
- dns name compression write failure
Due to a logic flaw dns name compression writing was not properly implemented
which would result in the name prefix not being written for a partial match.
Fixes Bug: #757
Fix By: Brad House (@bradh352)
GitHub (8 May 2024)
- [Brad House brought this change]
CI: Add Netbsd workflow (#756)
Add NetBSD as a test target for CI.
Fix By: Brad House (@bradh352)
- [Brad House brought this change]
CI: OpenBSD (#755)
Github actions appears to support building on a few "unsupported"
platforms these days:
https://github.com/cross-platform-actions/action
Lets go ahead and add OpenBSD to try to prevent issues like #754
Fix By: Brad House (@bradh352)
- [Volker Schlecht brought this change]
Revert PR #659 (#754)
As described in https://github.com/c-ares/c-ares/issues/753 the change
merged with https://github.com/c-ares/c-ares/pull/659 is ill-advised and
leads to breakage in applications using c-ares on OpenBSD.
See also https://github.com/nodejs/node/issues/52439
Brad House (7 May 2024)
- static analyzer warning from 48e8cd2
Fixes new issue from last commit.
- ares_getnameinfo(): loosen validation on salen
salen validation should be greater than or equal to the required
storage size. Its not uncommon to use `struct sockaddr_storage` in
modern code which is definitely larger than `struct sockaddr_in` and
on some systems even larger than `struct sockaddr_in6`.
Fixes Issue: #752
Fix By: Brad House (@bradh352)
- ares_reinit(): reduce locked duration
- add missing copyrights
- manpage: remove AUTHOR section
The current best practices consider the AUTHOR section to be deprecated
and recommend removing such a section.
- fix endianness from PR #750
GitHub (29 Apr 2024)
- [Brad House brought this change]
Apple: reimplement DNS configuration reading (#750)
The DNS configuration for apple is stored in the system configuration
database. Apple does provide an emulated `/etc/resolv.conf` on MacOS
(but not iOS), it cannot, however, represent the entirety of the DNS
configuration. Alternatively, libresolv could be used to also retrieve
some system configuration, but it too is not capable of retrieving the
entirety of the DNS configuration.
Attempts to use the preferred public API of `SCDynamicStoreCreate()` and
friends yielded incomplete DNS information. Instead, that leaves some
apple "internal" symbols from `configd` that we need to access in order
to get the entire configuration. We can see that we're not the only ones
to do this as Google Chrome also does:
https://chromium.googlesource.com/chromium/src/+/HEAD/net/dns/dns_config_watcher_mac.cc
These internal functions are what what`libresolv` and `scutil` use to
retrieve the dns configuration. Since these symbols are not publicly
available, we will dynamically load the symbols from `libSystem` and
import the `dnsinfo.h` private header extracted from:
https://opensource.apple.com/source/configd/configd-1109.140.1/dnsinfo/dnsinfo.h
Fix By: Brad House (@bradh352)
- [Oliver Welsh brought this change]
Add observability into DNS server health via a server state callback, invoked whenever a query finishes (#744)
**Summary**
This PR adds a server state callback that is invoked whenever a query to
a DNS server finishes.
The callback is invoked with the server details (as a string), a boolean
indicating whether the query succeeded or failed, flags describing the
query (currently just indicating whether TCP or UDP was used), and
custom userdata.
This can be used by user applications to gain observability into DNS
server health and usage. For example, alerts when a DNS server
fails/recovers or metrics to track how often a DNS server is used and
responds successfully.
**Testing**
Three new regression tests `MockChannelTest.ServStateCallback*` have
been added to test the new callback in different success/failure
scenarios.
Fix By: Oliver Welsh (@oliverwelsh)
Brad House (25 Apr 2024)
- ares_init_options() fix crash on misuse of event thread options
If an invalid event thread system was provided, it would crash during cleanup due to a NULL pointer dereference.
Fixes Issue: #749
Fix By: Brad House (@bradh352)
GitHub (22 Apr 2024)
- [Oliver Welsh brought this change]
Improve reliability in the server retry delay regression tests (#747)
Improve reliability in the server retry delay regression tests by
increasing the retry delay and sleeping for a little more than the retry
delay when attempting to force retries.
This helps to account for unreliable timing (e.g. NTP slew)
intermittently breaking pipelines.
Fix By: Oliver Welsh (@oliverwelsh)
- [Jiwoo Park brought this change]
cmake: Android requires C99 (#748)
I tried to build c-ares using CMake with the latest Android NDK
(r26/27), but failed as follows.
```
Building C object _deps/c-ares-source-build/src/lib/CMakeFiles/c-ares.dir/Debug/ares__buf.c.o
FAILED: _deps/c-ares-source-build/src/lib/CMakeFiles/c-ares.dir/Debug/ares__buf.c.o
In file included from c-ares/src/lib/ares__buf.c:27:
In file included from c-ares/include/ares.h:85:
In file included from Android/sdk/ndk/27.0.11718014/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/netinet/in.h:36:
In file included from Android/sdk/ndk/27.0.11718014/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/linux/in.h:231:
In file included from Android/sdk/ndk/27.0.11718014/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/aarch64-linux-android/asm/byteorder.h:12:
In file included from Android/sdk/ndk/27.0.11718014/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/linux/byteorder/little_endian.h:17:
Android/sdk/ndk/27.0.11718014/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/linux/swab.h:28:8: error: unknown type name 'inline'
28 | static inline __attribute__((__const__)) __u32 __fswahw32(__u32 val) {
| ^
Android/sdk/ndk/27.0.11718014/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/linux/swab.h:28:47: error: expected ';' after top level declarator
28 | static inline __attribute__((__const__)) __u32 __fswahw32(__u32 val) {
| ^
```
It looks like the NDK recently added C99 code containing `inline`
functions, but c-ares is setting the `C_STANDARD` CMake property to C90.
Fix By: Jiwoo Park (@jimmy-park)
- [Aviv Keller brought this change]
Use gender-neutral language in SECURITY.md (#746)
This PR updates the SECURITY.md file to use more gender-inclusive
language.
Fix By: Aviv Keller (@RedYetiDev)
Brad House (15 Apr 2024)
- check for spurious wakeup
- ares_queue_wait_empty() does not honor timeout_ms >= 0
There is a missing break statement in the case that timeout_ms >= 0
leading to a possible infinite loop.
Fixes Issue: #742
Fix By: Brad House (@bradh352)
GitHub (14 Apr 2024)
- [Oliver Welsh brought this change]
Add server failover retry behavior, where failed servers are retried with small probability after a minimum delay (#731)
**Summary**
By default c-ares will select the server with the least number of
consecutive failures when sending a query. However, this means that if a
server temporarily goes down and hits failures (e.g. a transient network
issue), then that server will never be retried until all other servers
hit the same number of failures.
This is an issue if the failed server is preferred to other servers in
the list. For example if a primary server and a backup server are
configured.
This PR adds new server failover retry behavior, where failed servers
are retried with small probability after a minimum delay has passed. The
probability and minimum delay are configurable via the
`ARES_OPT_SERVER_FAILOVER` option. By default c-ares will use a
probability of 10% and a minimum delay of 5 seconds.
In addition, this PR includes a small change to always close out
connections to servers which have hit failures, even with
`ARES_FLAG_STAYOPEN`. It's possible that resetting the connection can
resolve some server issues (e.g. by resetting the source port).
**Testing**
A new set of regression tests have been added to test the new server
failover retry behavior.
Fixes Issue: #717
Fix By: Oliver Welsh (@oliverwelsh)
Brad House (4 Apr 2024)
- MacOS/iOS: Apple does not allow users to configure DNS resolution timeouts or number of retries as Apple themselves uses dynamic/algorithmic values for their own resolver, so we should disable reading these static dummy values.
GitHub (30 Mar 2024)
- [Chenyu Yang brought this change]
CMake: remove duplicate checks for sys/random.h (#740)
Fix By: Chenyu Yang (@Ch3nYuY)
Version 1.28.1 (30 Mar 2024)
GitHub (30 Mar 2024)
@ -6189,159 +6482,3 @@ Daniel Stenberg (30 Aug 2013)
- timeadd: make static
ares__timeadd() was only ever used from within the same source
Yang Tse (18 Jul 2013)
- xc-am-iface.m4: comments refinement
- configure: fix 'subdir-objects' distclean related issue
See XC_AMEND_DISTCLEAN comments for details.
- configure: automake 1.14 compatibility tweak (use XC_AUTOMAKE)
- xc-am-iface.m4: provide XC_AUTOMAKE macro
Daniel Stenberg (12 May 2013)
- gitignore: ignore all ares_*pdf but also CHANGES.dist
- bump: start working towards 1.10.1
Version 1.10.0 (12 May 2013)
Daniel Stenberg (12 May 2013)
- RELEASE-NOTES: two more bug fixes
- [Keith Shaw brought this change]
ares_set_servers_csv: fixed IPv6 address parsing
Fixed bug that caused the last part of an IPv6 address to be parsed as
the port number when the last part is all numeric.
- nroff: fix two syntax mistakes
ares_parse_a_reply and ares_parse_aaaa_reply both had two \fB instead of
\fP
Reported-by: Alexander Klauer
Bug: http://c-ares.haxx.se/mail/c-ares-archive-2013-03/0010.shtml
- [Alex Loukissas brought this change]
build: fix build on msvc11
- Makefile.am: increment -version-info for 1.10.0 release
- README: remove unnecessary comment
- ares_version.h: copyright end range year is now 2013
- RELEASE-NOTES: synced with fb0737f3a0a1c37
- [Paul Saab brought this change]
ares_parse_aaaa_reply: Plug memory leak
This change is similar to ares_parse_a_reply.c in commit
bffd67f16a8f42fe6dbf79ab2e39d92eea05c8a6
- [Patrick Valsecchi brought this change]
ares_parse_txt_reply: return a ares_txt_reply node for each sub-string
Previously, the function would wrongly return all substrings merged into
one.
- [Alexander Klauer brought this change]
library init: documentation update
This commit updates the documentation of ares_library_init() and
ares_library_cleanup() with regard to the newly introduced reference
counting of initializations and deinitializations.
- [Alexander Klauer brought this change]
library init: be recursive
Previously, a single call to ares_library_cleanup() would deinitialise
the c-ares library, regardless of how many times ares_library_init() was
called. This behaviour may cause problems in programs linking two or
more libraries which, in turn, use c-ares. The present commit fixes this
problem, deinitializing the library only after a number of calls to
ares_library_cleanup() matching the number of calls to
ares_library_init().
- [Patrick Valsecchi brought this change]
protocol parsing: check input data stricter
... so that bad length fields aren't blindly accepted
Bug: http://c-ares.haxx.se/mail/c-ares-archive-2013-04/0016.shtml
Guenter Knauf (11 Apr 2013)
- Create ares_build.h when buidling from Git.
- Added -DCARES_STATICLIB to CFLAGS.
Currently this static makefile does only support building the
static library libcares.a.
Daniel Stenberg (8 Apr 2013)
- [Alexander Klauer brought this change]
.gitignore: ignore patch files
This commit adds a line to .gitignore to the effect that patch files
generated by 'git format-patch' are excluded from the repository.
- [Alexander Klauer brought this change]
ares_destroy() documentation: no new requests
Clarify that no new requests may be added to a resolver channel that is
currently being destroyed.
- [Alexander Klauer brought this change]
Documentation: properly document ARES_ECANCELLED
This commit clarifies the behaviour of ares_cancel() with respect to
callbacks and adds missing documentation of ARES_ECANCELLED to the man
pages of the affected functions.
- [Alexander Klauer brought this change]
ares_cancel(): cancel requests safely
An invocation of ares_cancel() walks through the request list, calling
the callbacks of all pending requests on a channel. Previously, if such
a callback added a new request to the channel, the request list might
not end up empty, causing an abort by assertion failure. The present
commit ensures that precisely all requests present upon entry of
ares_cancel() are cancelled, and that adding new requests through
callbacks is safe.
Yang Tse (10 Mar 2013)
- ares.h: stricter CARES_EXTERN linkage decorations logic
No API change involved.
- ares_build.h.dist: enhance non-configure GCC ABI detection logic
GCC specific adjustments:
- check __ILP32__ before 32 and 64bit processor architectures in
order to detect ILP32 programming model on 64 bit processors
which, of course, also support LP64 programming model, when using
gcc 4.7 or newer.
- keep 32bit processor architecture checks in order to support gcc
versions older than 4.7 which don't define __ILP32__
- check __LP64__ for gcc 3.3 and newer, while keeping 64bit processor
architecture checks for older versions which don't define __LP64__
Daniel Stenberg (9 Mar 2013)
- ares.h: there is no ares_free_soa function

View file

@ -12,10 +12,10 @@ INCLUDE (CheckCSourceCompiles)
INCLUDE (CheckStructHasMember)
INCLUDE (CheckLibraryExists)
PROJECT (c-ares LANGUAGES C VERSION "1.28.1" )
PROJECT (c-ares LANGUAGES C VERSION "1.29.0" )
# Set this version before release
SET (CARES_VERSION "1.28.1")
SET (CARES_VERSION "1.29.0")
INCLUDE (GNUInstallDirs) # include this *AFTER* PROJECT(), otherwise paths are wrong.
@ -30,7 +30,7 @@ INCLUDE (GNUInstallDirs) # include this *AFTER* PROJECT(), otherwise paths are w
# For example, a version of 4:0:2 would generate output such as:
# libname.so -> libname.so.2
# libname.so.2 -> libname.so.2.2.0
SET (CARES_LIB_VERSIONINFO "15:1:13")
SET (CARES_LIB_VERSIONINFO "16:0:14")
OPTION (CARES_STATIC "Build as a static library" OFF)
@ -172,7 +172,7 @@ return 0;
MACOS_V1012)
ENDIF ()
IF ((IOS OR APPLE OR ZOS) AND HAVE_LIBRESOLV)
IF (ZOS AND HAVE_LIBRESOLV)
SET (CARES_USE_LIBRESOLV 1)
ENDIF()
@ -227,7 +227,6 @@ CHECK_INCLUDE_FILES (sys/select.h HAVE_SYS_SELECT_H)
CHECK_INCLUDE_FILES (sys/stat.h HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILES (sys/time.h HAVE_SYS_TIME_H)
CHECK_INCLUDE_FILES (sys/uio.h HAVE_SYS_UIO_H)
CHECK_INCLUDE_FILES (sys/random.h HAVE_SYS_RANDOM_H)
CHECK_INCLUDE_FILES (sys/event.h HAVE_SYS_EVENT_H)
CHECK_INCLUDE_FILES (sys/epoll.h HAVE_SYS_EPOLL_H)
CHECK_INCLUDE_FILES (ifaddrs.h HAVE_IFADDRS_H)
@ -341,7 +340,6 @@ CARES_EXTRAINCLUDE_IFSET (HAVE_SYS_SOCKIO_H sys/sockio.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_SYS_TIME_H sys/time.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_SYS_STAT_H sys/stat.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_SYS_UIO_H sys/uio.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_SYS_RANDOM_H sys/random.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_SYS_EVENT_H sys/event.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_SYS_EPOLL_H sys/epoll.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_TIME_H time.h)

View file

@ -1,7 +1,7 @@
# [![c-ares logo](https://c-ares.org/art/c-ares-logo.svg)](https://c-ares.org/)
[![Build Status](https://api.cirrus-ci.com/github/c-ares/c-ares.svg?branch=main)](https://cirrus-ci.com/github/c-ares/c-ares)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/aevgc5914tm72pvs/branch/master?svg=true)](https://ci.appveyor.com/project/c-ares/c-ares/branch/master)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/aevgc5914tm72pvs/branch/main?svg=true)](https://ci.appveyor.com/project/c-ares/c-ares/branch/main)
[![Coverage Status](https://coveralls.io/repos/github/c-ares/c-ares/badge.svg)](https://coveralls.io/github/c-ares/c-ares)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/291/badge)](https://bestpractices.coreinfrastructure.org/projects/291)
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/c-ares.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:c-ares)

View file

@ -1,49 +1,42 @@
## c-ares version 1.28.1 - Mar 30 2024
This release contains a fix for a single significant regression introduced
in c-ares 1.28.0.
* `ares_search()` and `ares_getaddrinfo()` resolution fails if no search domains
are specified. [Issue #737](https://github.com/c-ares/c-ares/issues/737)
## c-ares version 1.28.0 - Mar 29 2024
## c-ares version 1.29.0 - May 24 2024
This is a feature and bugfix release.
Features:
* Emit warnings when deprecated c-ares functions are used. This can be
disabled by passing a compiler definition of `CARES_NO_DEPRECATED`. [PR #732](https://github.com/c-ares/c-ares/pull/732)
* Add function `ares_search_dnsrec()` to search for records using the new DNS
record data structures. [PR #719](https://github.com/c-ares/c-ares/pull/719)
* Rework internals to pass around `ares_dns_record_t` instead of binary data,
this introduces new public functions of `ares_query_dnsrec()` and
`ares_send_dnsrec()`. [PR #730](https://github.com/c-ares/c-ares/pull/730)
* When using `ARES_OPT_EVENT_THREAD`, automatically reload system configuration
when network conditions change. [PR #759](https://github.com/c-ares/c-ares/pull/759)
* Apple: reimplement DNS configuration reading to more accurately pull DNS
settings. [PR #750](https://github.com/c-ares/c-ares/pull/750)
* Add observability into DNS server health via a server state callback, invoked
whenever a query finishes. [PR #744](https://github.com/c-ares/c-ares/pull/744)
* Add server failover retry behavior, where failed servers are retried with
small probability after a minimum delay. [PR #731](https://github.com/c-ares/c-ares/pull/731)
Changes:
* tests: when performing simulated queries, reduce timeouts to make tests run
faster
* Replace configuration file parsers with memory-safe parser. [PR #725](https://github.com/c-ares/c-ares/pull/725)
* Remove `acountry` completely, the manpage might still get installed otherwise. [Issue #718](https://github.com/c-ares/c-ares/pull/718)
* Mark `ares_channel_t *` as const in more places in the public API. [PR #758](https://github.com/c-ares/c-ares/pull/758)
Bugfixes:
* CMake: don't overwrite global required libraries/definitions/includes which
could cause build errors for projects chain building c-ares. [Issue #729](https://github.com/c-ares/c-ares/issues/729)
* On some platforms, `netinet6/in6.h` is not included by `netinet/in.h`
and needs to be included separately. [PR #728](https://github.com/c-ares/c-ares/pull/728)
* Fix a potential memory leak in `ares_init()`. [Issue #724](https://github.com/c-ares/c-ares/issues/724)
* Some platforms don't have the `isascii()` function. Implement as a macro. [PR #721](https://github.com/c-ares/c-ares/pull/721)
* CMake: Fix Chain building if CMAKE runtime paths not set
* NDots configuration should allow a value of zero. [PR #735](https://github.com/c-ares/c-ares/pull/735)
* Due to a logic flaw dns name compression writing was not properly implemented
which would result in the name prefix not being written for a partial match.
This could cause issues in various record types such as MX records when using
the deprecated API. Regression introduced in 1.28.0. [Issue #757](https://github.com/c-ares/c-ares/issues/757)
* Revert OpenBSD `SOCK_DNS` flag, it doesn't do what the docs say it does and
causes c-ares to become non-functional. [PR #754](https://github.com/c-ares/c-ares/pull/754)
* `ares_getnameinfo()`: loosen validation on `salen` parameter. [Issue #752](https://github.com/c-ares/c-ares/issues/752)
* cmake: Android requires C99. [PR #748](https://github.com/c-ares/c-ares/pull/748)
* `ares_queue_wait_empty()` does not honor timeout_ms >= 0. [Issue #742](https://github.com/c-ares/c-ares/pull/742)
Thanks go to these friendly people for their efforts and contributions for this release:
Thanks go to these friendly people for their efforts and contributions for this
release:
* Brad House (@bradh352)
* Cristian Rodríguez (@crrodriguez)
* Daniel Stenberg (@bagder)
* Faraz (@farazrbx)
* Faraz Fallahi (@fffaraz)
* David Hotham (@dimbleby)
* Jiwoo Park (@jimmy-park)
* Oliver Welsh (@oliverwelsh)
* Volker Schlecht (@VlkrS)

View file

@ -43,7 +43,7 @@ announcement.
- If the report is rejected, the team writes to the reporter to explain why.
- If the report is accepted, the team writes to the reporter to let him/her
- If the report is accepted, the team writes to the reporter to let them
know it is accepted and that they are working on a fix.
- The security team discusses the problem, works out a fix, considers the

View file

@ -1,6 +1,6 @@
# aminclude_static.am generated automatically by Autoconf
# from AX_AM_MACROS_STATIC on Sat Mar 30 16:17:17 CET 2024
# from AX_AM_MACROS_STATIC on Fri May 24 08:50:03 CEST 2024
# Code coverage

12
deps/cares/cares.gyp vendored
View file

@ -21,6 +21,8 @@
'src/lib/ares__htable_strvp.h',
'src/lib/ares__htable_szvp.c',
'src/lib/ares__htable_szvp.h',
'src/lib/ares__htable_vpvp.c',
'src/lib/ares__htable_vpvp.h',
'src/lib/ares__iface_ips.c',
'src/lib/ares__iface_ips.h',
'src/lib/ares__llist.c',
@ -46,6 +48,7 @@
'src/lib/ares_dns_record.c',
'src/lib/ares_dns_private.h',
'src/lib/ares_dns_write.c',
'src/lib/ares_event_configchg.c',
'src/lib/ares_event.h',
'src/lib/ares_event_win32.h',
'src/lib/ares_event_epoll.c',
@ -113,6 +116,11 @@
'src/tools/ares_getopt.c',
'src/tools/ares_getopt.h',
],
'cares_sources_mac': [
'config/darwin/ares_config.h',
'src/lib/ares_sysconfig_mac.c',
'src/lib/thirdparty/apple/dnsinfo.h',
],
'cares_sources_win': [
'src/lib/config-win32.h',
'src/lib/windows_port.c',
@ -206,7 +214,9 @@
}],
[ 'OS=="mac" or OS=="ios"', {
'include_dirs': [ 'config/darwin' ],
'sources': [ 'config/darwin/ares_config.h' ]
'sources': [
'<@(cares_sources_mac)',
]
}],
[ 'OS=="freebsd" or OS=="dragonflybsd"', {
'include_dirs': [ 'config/freebsd' ],

95
deps/cares/configure vendored
View file

@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.71 for c-ares 1.28.1.
# Generated by GNU Autoconf 2.71 for c-ares 1.29.0.
#
# Report bugs to <c-ares mailing list: http://lists.haxx.se/listinfo/c-ares>.
#
@ -621,8 +621,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='c-ares'
PACKAGE_TARNAME='c-ares'
PACKAGE_VERSION='1.28.1'
PACKAGE_STRING='c-ares 1.28.1'
PACKAGE_VERSION='1.29.0'
PACKAGE_STRING='c-ares 1.29.0'
PACKAGE_BUGREPORT='c-ares mailing list: http://lists.haxx.se/listinfo/c-ares'
PACKAGE_URL=''
@ -1420,7 +1420,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures c-ares 1.28.1 to adapt to many kinds of systems.
\`configure' configures c-ares 1.29.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1491,7 +1491,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of c-ares 1.28.1:";;
short | recursive ) echo "Configuration of c-ares 1.29.0:";;
esac
cat <<\_ACEOF
@ -1627,7 +1627,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
c-ares configure 1.28.1
c-ares configure 1.29.0
generated by GNU Autoconf 2.71
Copyright (C) 2021 Free Software Foundation, Inc.
@ -2251,7 +2251,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by c-ares $as_me 1.28.1, which was
It was created by c-ares $as_me 1.29.0, which was
generated by GNU Autoconf 2.71. Invocation command line was
$ $0$ac_configure_args_raw
@ -3225,7 +3225,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
CARES_VERSION_INFO="15:1:13"
CARES_VERSION_INFO="16:0:14"
@ -5907,7 +5907,7 @@ fi
# Define the identity of the package.
PACKAGE='c-ares'
VERSION='1.28.1'
VERSION='1.29.0'
printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
@ -20946,79 +20946,6 @@ esac
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $need_xnet" >&5
printf "%s\n" "$need_xnet" >&6; }
if test "x$host_vendor" = "xapple"
then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing res_servicename" >&5
printf %s "checking for library containing res_servicename... " >&6; }
if test ${ac_cv_search_res_servicename+y}
then :
printf %s "(cached) " >&6
else $as_nop
ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
char res_servicename ();
int
main (void)
{
return res_servicename ();
;
return 0;
}
_ACEOF
for ac_lib in '' resolv
do
if test -z "$ac_lib"; then
ac_res="none required"
else
ac_res=-l$ac_lib
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
if ac_fn_c_try_link "$LINENO"
then :
ac_cv_search_res_servicename=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext
if test ${ac_cv_search_res_servicename+y}
then :
break
fi
done
if test ${ac_cv_search_res_servicename+y}
then :
else $as_nop
ac_cv_search_res_servicename=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_res_servicename" >&5
printf "%s\n" "$ac_cv_search_res_servicename" >&6; }
ac_res=$ac_cv_search_res_servicename
if test "$ac_res" != no
then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
printf "%s\n" "#define CARES_USE_LIBRESOLV 1" >>confdefs.h
else $as_nop
as_fn_error $? "Unable to find libresolv which is required for iPhone targets" "$LINENO" 5
fi
fi
if test "x$host_vendor" = "xibm" -a "x$host_os" = "xopenedition"
then :
@ -25956,7 +25883,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by c-ares $as_me 1.28.1, which was
This file was extended by c-ares $as_me 1.29.0, which was
generated by GNU Autoconf 2.71. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -26024,7 +25951,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config='$ac_cs_config_escaped'
ac_cs_version="\\
c-ares config.status 1.28.1
c-ares config.status 1.29.0
configured by $0, generated by GNU Autoconf 2.71,
with options \\"\$ac_cs_config\\"

View file

@ -2,10 +2,10 @@ dnl Copyright (C) The c-ares project and its contributors
dnl SPDX-License-Identifier: MIT
AC_PREREQ([2.69])
AC_INIT([c-ares], [1.28.1],
AC_INIT([c-ares], [1.29.0],
[c-ares mailing list: http://lists.haxx.se/listinfo/c-ares])
CARES_VERSION_INFO="15:1:13"
CARES_VERSION_INFO="16:0:14"
dnl This flag accepts an argument of the form current[:revision[:age]]. So,
dnl passing -version-info 3:12:1 sets current to 3, revision to 12, and age to
dnl 1.
@ -334,15 +334,6 @@ case $host_os in
esac
AC_MSG_RESULT($need_xnet)
dnl resolv lib for Apple (MacOS and iOS)
AS_IF([test "x$host_vendor" = "xapple"], [
AC_SEARCH_LIBS([res_servicename], [resolv], [
AC_DEFINE([CARES_USE_LIBRESOLV], [1], [Use resolver library to configure cares])
], [
AC_MSG_ERROR([Unable to find libresolv which is required for iPhone targets])
])
])
dnl resolv lib for z/OS
AS_IF([test "x$host_vendor" = "xibm" -a "x$host_os" = "xopenedition" ], [
AC_SEARCH_LIBS([res_init], [resolv], [

View file

@ -460,6 +460,7 @@ MANPAGES = ares_cancel.3 \
ares_set_local_dev.3 \
ares_set_local_ip4.3 \
ares_set_local_ip6.3 \
ares_set_server_state_callback.3 \
ares_set_servers.3 \
ares_set_servers_csv.3 \
ares_set_servers_ports.3 \

View file

@ -122,6 +122,7 @@ MANPAGES = ares_cancel.3 \
ares_set_local_dev.3 \
ares_set_local_ip4.3 \
ares_set_local_ip6.3 \
ares_set_server_state_callback.3 \
ares_set_servers.3 \
ares_set_servers_csv.3 \
ares_set_servers_ports.3 \

View file

@ -31,5 +31,3 @@ c-ares 1.6.0 and earlier pass a status of
.BR ARES_ETIMEOUT
instead of
.BR ARES_ECANCELLED .
.SH AUTHOR
Dirk Manske

View file

@ -70,4 +70,3 @@ Added in c-ares 1.10.0
.BR ares_expand_name (3),
.BR ares_free_string (3),
.BR ares_mkquery (3)
.SH AUTHOR

View file

@ -27,7 +27,3 @@ using this channel may be made once this function is called.
.BR ares_init (3),
.BR ares_cancel (3),
.BR ares_threadsafety (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.

View file

@ -18,7 +18,3 @@ identified by \Ioptions\fP, freeing all memory allocated by
.SH SEE ALSO
.BR ares_save_options (3),
.BR ares_init_options (3)
.SH AUTHOR
Brad House
.br
Copyright 1998 by the Massachusetts Institute of Technology.

View file

@ -298,5 +298,3 @@ These functions were first introduced in c-ares version 1.22.0.
.BR ares_dns_record (3),
.BR ares_dns_rr (3),
.BR ares_init (3)
.SH AUTHOR
Copyright (C) 2023 The c-ares project and its members.

View file

@ -439,5 +439,3 @@ These functions were first introduced in c-ares version 1.22.0.
.BR ares_dns_mapping (3),
.BR ares_dns_rr (3),
.BR ares_free_string (3)
.SH AUTHOR
Copyright (C) 2023 The c-ares project and its members.

View file

@ -635,5 +635,3 @@ These functions were first introduced in c-ares version 1.22.0.
.BR ares_dns_mapping (3),
.BR ares_dns_record (3),
.BR ares_free_string (3)
.SH AUTHOR
Copyright (C) 2023 The c-ares project and its members.

View file

@ -9,7 +9,7 @@ ares_dup \- Duplicate a resolver channel
.nf
#include <ares.h>
int ares_dup(ares_channel_t **\fIdest\fP, ares_channel_t *\fIsource\fP)
int ares_dup(ares_channel_t **\fIdest\fP, const ares_channel_t *\fIsource\fP)
.fi
.SH DESCRIPTION
The \fBares_dup(3)\fP function duplicates an existing communications channel
@ -23,6 +23,3 @@ handle when the channel is no longer needed.
.BR ares_library_init (3)
.SH AVAILABILITY
\fIares_dup(3)\fP was added in c-ares 1.6.0
.SH AUTHOR
Daniel Stenberg

View file

@ -49,7 +49,3 @@ Memory was exhausted.
.SH SEE ALSO
.BR ares_mkquery (3),
.BR ares_free_string (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.

View file

@ -46,5 +46,3 @@ The encoded string was malformed and could not be expanded.
Memory was exhausted.
.SH SEE ALSO
.BR ares_free_string (3)
.SH AUTHOR
Dominick Meglio

View file

@ -9,7 +9,7 @@ ares_fds \- return file descriptors to select on (deprecated)
.nf
#include <ares.h>
int ares_fds(ares_channel_t *\fIchannel\fP,
int ares_fds(const ares_channel_t *\fIchannel\fP,
fd_set *\fIread_fds\fP,
fd_set *\fIwrite_fds\fP)
.fi
@ -55,7 +55,3 @@ more modern methods to check for socket readable/writable state such as
.BR ares_init_options (3),
.BR ares_timeout (3),
.BR ares_process (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.

View file

@ -60,9 +60,3 @@ This function was first introduced in c-ares version 1.7.0.
.BR ares_parse_mx_reply (3),
.BR ares_parse_txt_reply (3),
.BR ares_parse_soa_reply (3)
.SH AUTHOR
Yang Tse
.PP
Copyright 1998 by the Massachusetts Institute of Technology.
.br
Copyright (C) 2004-2010 by Daniel Stenberg.

View file

@ -28,7 +28,3 @@ structures when the callback returns.
.BR ares_parse_aaaa_reply (3),
.BR ares_parse_ptr_reply (3),
.BR ares_parse_ns_reply (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.

View file

@ -17,7 +17,3 @@ function.
.SH SEE ALSO
.BR ares_mkquery (3)
.BR ares_expand_string (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 2000 by the Massachusetts Institute of Technology.

View file

@ -20,7 +20,3 @@ returned in \fIresult\fP of
.B ares_addrinfo_callback
.SH SEE ALSO
.BR ares_getaddrinfo (3),
.SH AUTHOR
Christian Ammer
.BR
Andrew Selivanov <andrew.selivanov@gmail.com>

View file

@ -10,10 +10,10 @@ ares_get_servers, ares_get_servers_ports \- Retrieve name servers from an initia
.nf
#include <ares.h>
int ares_get_servers(ares_channel_t *\fIchannel\fP,
int ares_get_servers(const ares_channel_t *\fIchannel\fP,
struct ares_addr_node **\fIservers\fP)
int ares_get_servers_ports(ares_channel_t *\fIchannel\fP,
int ares_get_servers_ports(const ares_channel_t *\fIchannel\fP,
struct ares_addr_port_node **\fIservers\fP)
.fi
.SH DESCRIPTION
@ -67,13 +67,3 @@ was invalid.
.SH NOTES
As of c-ares 1.24, these functions are deprecated due to their lack of ability
to store the entire server configuration. Use \fBares_get_servers_csv(3)\fP.
.SH AUTHOR
Implementation of this function and associated library internals are based
on code, comments and feedback provided in November and December of 2008 by
Daniel Stenberg, Gregor Jasny, Phil Blundell and Yang Tse, December 2009
by Cedric Bail, February 2010 by Jakub Hrozek. On March 2010 Yang Tse
shuffled all the bits and this function popped out.
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.br
Copyright (C) 2008-2010 by Daniel Stenberg

View file

@ -192,7 +192,3 @@ on each of the resolved addresses as per RFC6724.
This function was added in c-ares 1.16.0, released in March 2020.
.SH SEE ALSO
.BR ares_freeaddrinfo (3)
.SH AUTHOR
Christian Ammer
.br
Andrew Selivanov <andrew.selivanov@gmail.com>

View file

@ -98,7 +98,3 @@ within the eventloop when notified.
.SH SEE ALSO
.BR ares_process (3),
.BR ares_gethostbyname (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.

View file

@ -106,7 +106,3 @@ within the eventloop when notified.
.SH SEE ALSO
.BR ares_process (3),
.BR ares_gethostbyaddr (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.

View file

@ -66,7 +66,3 @@ Added in c-ares 1.5.4
.BR ares_gethostbyname (3),
.BR ares_free_hostent (3),
.BR ares_init_options (3)
.SH AUTHOR
Brad Spencer
.br
Copyright 1998 by the Massachusetts Institute of Technology.

View file

@ -145,7 +145,3 @@ will be
.BR NULL .
.SH SEE ALSO
.BR ares_process (3),
.SH AUTHOR
Dominick Meglio
.br
Copyright 2005 by Dominick Meglio.

View file

@ -9,7 +9,7 @@ ares_getsock \- get socket descriptors to wait on (deprecated)
.nf
#include <ares.h>
int ares_getsock(ares_channel_t *\fIchannel\fP, ares_socket_t *\fIsocks\fP,
int ares_getsock(const ares_channel_t *\fIchannel\fP, ares_socket_t *\fIsocks\fP,
int \fInumsocks\fP);
.fi
.SH DESCRIPTION

View file

@ -31,6 +31,4 @@ for IPv6).
.BR ares_inet_pton (3)
.SH AVAILABILITY
made properly publicly available in c-ares for real in version 1.10.0
.SH AUTHOR
Daniel Stenberg

View file

@ -27,6 +27,4 @@ the numeric address; this shall be large enough to hold the numeric address
.BR ares_inet_ntop (3)
.SH AVAILABILITY
made properly publicly available in c-ares for real in version 1.10.0
.SH AUTHOR
Daniel Stenberg

View file

@ -11,6 +11,11 @@ ares_init_options, ares_init \- Initialize a resolver channel
.nf
#include <ares.h>
struct ares_server_failover_options {
unsigned short retry_chance;
size_t retry_delay;
};
struct ares_options {
int flags;
int timeout; /* in seconds or milliseconds, depending on options */
@ -36,6 +41,7 @@ struct ares_options {
int maxtimeout; /* in milliseconds */
unsigned int qcache_max_ttl; /* in seconds */
ares_evsys_t evsys;
struct ares_server_failover_options server_failover_opts;
};
int ares_init_options(ares_channel_t **\fIchannelptr\fP,
@ -309,6 +315,9 @@ When enabled, the integrator is no longer responsible for notifying c-ares of
any events on the file descriptors, so \fIares_process(3)\fP nor
\fIares_process_fd(3)\fP should ever be called when this option is enabled.
As of c-ares 1.29.0, when enabled, it will also automatically re-load the
system configuration when changes are detected.
Use \fIares_threadsafety(3)\fP to determine if this option is available to be
used.
@ -316,6 +325,24 @@ Returns \fBARES_ENOTIMP\fP if this option is passed but not available, and
\fBARES_ESERVFAIL\fP if there is a critical failure during initialization of
the event thread.
.br
.TP 18
.B ARES_OPT_SERVER_FAILOVER
.B struct ares_server_failover_options \fIserver_failover_opts\fP;
.br
Configure server failover retry behavior. When a DNS server fails to
respond to a query, c-ares will deprioritize the server. On subsequent
queries, servers with fewer consecutive failures will be selected in
preference. However, in order to detect when such a server has recovered,
c-ares will occasionally retry failed servers. The
\fIares_server_failover_options\fP structure contains options to control this
behavior.
The \fIretry_chance\fP field gives the probability (1/N) of retrying a
failed server on any given query. Setting to a value of 0 disables retries.
The \fIretry_delay\fP field gives the minimum delay in milliseconds that c-ares
will wait before retrying a specific failed server.
If this option is not specificed then c-ares will use a probability of 10%
and a minimum delay of 5 seconds.
.br
.PP
The \fIoptmask\fP parameter also includes options without a corresponding
field in the
@ -371,9 +398,3 @@ manual page.
.BR ares_set_servers (3),
.BR ares_set_sortlist (3),
.BR ares_threadsafety (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.br
Copyright (C) 2004-2010 by Daniel Stenberg.

View file

@ -64,9 +64,3 @@ a do-nothing function on non-Win32/64 platforms.
.SH SEE ALSO
.BR ares_library_init (3),
.BR ares_cancel (3)
.SH AUTHOR
Yang Tse
.PP
Copyright 1998 by the Massachusetts Institute of Technology.
.br
Copyright (C) 2004-2009 by Daniel Stenberg.

View file

@ -96,9 +96,3 @@ a do-nothing function on non-Win32/64 platforms at this point.
.SH SEE ALSO
.BR ares_library_cleanup (3),
.BR ares_strerror (3)
.SH AUTHOR
Yang Tse
.PP
Copyright 1998 by the Massachusetts Institute of Technology.
.br
Copyright (C) 2004-2009 by Daniel Stenberg.

View file

@ -124,8 +124,4 @@ This function was first introduced in c-ares version 1.15.0.
.SH SEE ALSO
.BR ares_library_init (3),
.BR ares_library_cleanup (3),
.SH AUTHOR
John Schember
.PP
Copyright (C) 2017 by John Schember

View file

@ -73,7 +73,3 @@ Memory was exhausted.
.BR ares_expand_name (3),
.BR ares_dns_record (3),
.BR ares_free_string (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998, 2000 by the Massachusetts Institute of Technology.

View file

@ -61,9 +61,3 @@ Memory was exhausted.
.SH SEE ALSO
.BR ares_gethostbyname (3),
.BR ares_free_hostent (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Andrew Selivanov <andrew.selivanov@gmail.com>
.br
Copyright 1998 by the Massachusetts Institute of Technology.

View file

@ -61,9 +61,3 @@ Memory was exhausted.
.SH SEE ALSO
.BR ares_gethostbyname (3),
.BR ares_free_hostent (3)
.SH AUTHOR
Dominick Meglio
.br
Copyright 2005 by Dominick Meglio.
.BR
Andrew Selivanov <andrew.selivanov@gmail.com>

View file

@ -156,5 +156,3 @@ This function was first introduced in c-ares version 1.17.0.
.SH SEE ALSO
.BR ares_query (3)
.BR ares_free_data (3)
.SH AUTHOR
Written by Danny Sonnenschein <my.card.god@web.de>, on behalf of platynum, https://platynum.ch

View file

@ -63,5 +63,3 @@ This function was first introduced in c-ares version 1.7.2.
.SH SEE ALSO
.BR ares_query (3)
.BR ares_free_data (3)
.SH AUTHOR
Written by Jeremy Lal <kapouer@melix.org>

View file

@ -68,5 +68,3 @@ This function was first introduced in c-ares version 1.7.6.
.SH SEE ALSO
.BR ares_query (3)
.BR ares_free_data (3)
.SH AUTHOR
Written by Jakub Hrozek <jhrozek@redhat.com>, on behalf of Red Hat, Inc http://www.redhat.com

View file

@ -51,5 +51,3 @@ Memory was exhausted.
.SH SEE ALSO
.BR ares_query (3),
.BR ares_free_hostent (3)
.SH AUTHOR
Written by Vlad Dinulescu <vlad.dinulescu@avira.com>, on behalf of AVIRA Gmbh http://www.avira.com

View file

@ -57,7 +57,3 @@ Memory was exhausted.
.SH SEE ALSO
.BR ares_gethostbyaddr (3),
.BR ares_free_hostent (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.

View file

@ -66,5 +66,3 @@ This function was first introduced in c-ares version 1.7.0.
.SH SEE ALSO
.BR ares_query (3)
.BR ares_free_data (3)
.SH AUTHOR
Written by Jakub Hrozek <jhrozek@redhat.com>, on behalf of Red Hat, Inc http://www.redhat.com

View file

@ -94,7 +94,3 @@ This function was first introduced in c-ares version 1.7.0.
.SH SEE ALSO
.BR ares_query (3)
.BR ares_free_data (3)
.SH AUTHOR
Written by Jakub Hrozek <jhrozek@redhat.com>, on behalf of Red Hat, Inc http://www.redhat.com
.PP
Amended by Fedor Indutny <fedor@indutny.com>, on behalf of PayPal, Inc https://www.paypal.com

View file

@ -60,5 +60,3 @@ Memory was exhausted.
.SH SEE ALSO
.BR ares_query (3)
.BR ares_free_data (3)
.SH AUTHOR
Written by Jan Petrasek <petrasek@tes.eu>

View file

@ -62,7 +62,3 @@ while (1) {
.SH SEE ALSO
.BR ares_fds (3),
.BR ares_timeout (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.

View file

@ -152,8 +152,3 @@ will be non-NULL, otherwise they will be NULL.
.SH SEE ALSO
.BR ares_process (3),
.BR ares_dns_record (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.

View file

@ -1,4 +1,5 @@
.\"
.\" Copyright 2024 by the c-ares project and its contributors
.\" SPDX-License-Identifier: MIT
.\"
.TH ARES_QUEUE 3 "16 February 2024"
@ -9,7 +10,7 @@ c-ares queue status
.nf
#include <ares.h>
size_t ares_queue_active_queries(ares_channel_t *channel);
size_t ares_queue_active_queries(const ares_channel_t *channel);
ares_status_t ares_queue_wait_empty(ares_channel_t *channel,
int timeout_ms);
@ -49,5 +50,3 @@ c-ares library to be built with threading support.
.SH SEE ALSO
.BR ares_init_options (3),
.BR ares_threadsafety (3)
.SH AUTHOR
Copyright (C) 2024 The c-ares project and its members.

View file

@ -1,4 +1,5 @@
.\"
.\" Copyright 2023 by the c-ares project and its contributors
.\" SPDX-License-Identifier: MIT
.\"
.TH ARES_REINIT 3 "12 November 2023"
@ -20,10 +21,13 @@ Any existing queries will be automatically requeued if the server they are
currently assigned to is removed from the system configuration.
This function may cause additional file descriptors to be created, and existing
ones to be destroyed if server configuration has changed. If this is called from
a thread other than which the main program event loop is running, care needs to
be taken to ensure any file descriptor lists are updated immediately within
the eventloop.
ones to be destroyed if server configuration has changed.
\Bares_reinit(3)\fP, when compiled with thread safety, will spawn a background
thread to read the configuration and apply it. It is crucial that developers
use the \fBARES_OPT_SOCK_STATE_CB\fP or \fBARES_OPT_EVENT_THREAD\fP so that
notifications of changes are alerted. If using \fBares_getsock(3)\fP or
\fBares_fds(3)\fP, no notification is possible which could cause a stall.
.SH RETURN VALUES
\fIares_reinit(3)\fP can return any of the following values:
@ -47,5 +51,3 @@ This function was first introduced in c-ares version 1.22.0.
.BR ares_library_init (3),
.BR ares_set_servers (3),
.BR ares_threadsafety (3)
.SH AUTHOR
Copyright (C) 2023 The c-ares project and its members.

View file

@ -9,7 +9,7 @@ ares_save_options \- Save configuration values obtained from initialized ares_ch
.nf
#include <ares.h>
int ares_save_options(ares_channel_t *\fIchannel\fP,
int ares_save_options(const ares_channel_t *\fIchannel\fP,
struct ares_options *\fIoptions\fP, int *\fIoptmask\fP)
.fi
.SH DESCRIPTION
@ -36,7 +36,7 @@ The channel data was successfully stored
The memory was exhausted
.TP 15
.B ARES_ENODATA
The channel data identified by
The channel data identified by
.IR channel
were invalid.
.SH NOTE
@ -58,7 +58,3 @@ used instead.
.BR ares_dup (3)
.SH AVAILABILITY
ares_save_options(3) was added in c-ares 1.4.0
.SH AUTHOR
Brad House
.br
Copyright 1998 by the Massachusetts Institute of Technology.

View file

@ -179,8 +179,3 @@ enqueuing of the query.
.SH SEE ALSO
.BR ares_process (3),
.BR ares_dns_record (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.

View file

@ -151,8 +151,3 @@ does not reflect as much about the response as for other query functions.
.BR ares_process (3),
.BR ares_search (3),
.BR ares_dns_record (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.

View file

@ -24,5 +24,3 @@ silently ignored.
.BR ares_set_local_ip6 (3)
.SH NOTES
This function was added in c-ares 1.7.4
.SH AUTHOR
Ben Greear

View file

@ -19,5 +19,3 @@ allows users to specify outbound interfaces when used on multi-homed systems.
.BR ares_set_local_ip6 (3)
.SH NOTES
This function was added in c-ares 1.7.4
.SH AUTHOR
Ben Greear

View file

@ -20,5 +20,3 @@ systems. The \fIlocal_ip6\fP argument must be 16 bytes in length.
.BR ares_set_local_ip4 (3)
.SH NOTES
This function was added in c-ares 1.7.4
.SH AUTHOR
Ben Greear

View file

@ -0,0 +1,62 @@
.\"
.\" Copyright 2024 by the c-ares project and its contributors
.\" SPDX-License-Identifier: MIT
.\"
.TH ARES_SET_SERVER_STATE_CALLBACK 3 "26 Apr 2024"
.SH NAME
ares_set_server_state_callback \- Function for setting a server state callback
.SH SYNOPSIS
.nf
#include <ares.h>
typedef void (*ares_server_state_callback)(const char *\fIserver_string\fP,
ares_bool_t \fIsuccess\fP,
int \fIflags\fP,
void *\fIdata\fP);
void ares_set_server_state_callback(ares_channel_t *\fIchannel\fP,
ares_server_state_callback \fIcallback\fP,
void *\fIuser_data\fP);
.fi
.SH DESCRIPTION
The \fBares_set_server_state_callback(3)\fP function sets a callback function
\fIcallback\fP in the given ares channel handle \fIchannel\fP that is invoked
whenever a query on the channel completes. This includes both successful and
unsuccessful queries (including hard errors and timeouts). The callback
function is invoked with a number of parameters describing the query, as
follows.
The \fIserver_string\fP parameter indicates the DNS server that was used for
the query, given as a string with the same format returned by
\fBares_get_servers_csv(3)\fP.
The \fIsuccess\fP parameter indicates whether the query succeeded or not. It is
set to \fBARES_TRUE\fP on success and \fBARES_FALSE\fP on failure.
The \fIflags\fP parameter is a bitmask of flags describing various aspects of
the query (for example whether the query used UDP or TCP). These are described
below.
The \fIdata\fP parameter is a reference to the custom user data \fIuser_data\fP
that was passed to \fBares_set_server_state_callback(3)\fP when setting the
server state callback.
The server state callback can be used by applications to monitor the state of
the DNS servers used by an ares channel. For example, it can be used to track
metrics about the numbers and types of queries sent to each server or to
detect when a server is uncontactable or unhealthy.
.SH FLAGS
.TP 5
.B ARES_SERV_STATE_UDP
Indicates that the query was tried over UDP.
.TP 5
.B ARES_SERV_STATE_TCP
Indicates that the query was tried over TCP.
.SH AVAILABILITY
This function was first introduced in c-ares version 1.29.0.
.SH SEE ALSO
.BR ares_get_servers_csv (3)

View file

@ -84,13 +84,3 @@ server options. Use \fBares_set_servers_csv(3)\fP.
.SH AVAILABILITY
\fBares_set_servers(3)\fP was added in c-ares 1.7.1;
\fBares_set_servers_ports(3)\fP was added in c-ares 1.11.0.
.SH AUTHOR
Implementation of this function and associated library internals are based
on code, comments and feedback provided in November and December of 2008 by
Daniel Stenberg, Gregor Jasny, Phil Blundell and Yang Tse, December 2009
by Cedric Bail, February 2010 by Jakub Hrozek. On March 2010 Yang Tse
shuffled all the bits and this function popped out.
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.br
Copyright (C) 2008-2010 by Daniel Stenberg

View file

@ -14,7 +14,7 @@ int ares_set_servers_csv(ares_channel_t *\fIchannel\fP, const char* \fIservers\f
int ares_set_servers_ports_csv(ares_channel_t *\fIchannel\fP, const char* \fIservers\fP)
char *ares_get_servers_csv(ares_channel_t *\fIchannel\fP)
char *ares_get_servers_csv(const ares_channel_t *\fIchannel\fP)
.fi
.SH DESCRIPTION
The \fBares_set_servers_csv\fP and \fBares_set_servers_ports_csv\fP functions set
@ -81,5 +81,3 @@ returns a string representing the servers configured which must be freed with
\fBares_set_servers_csv\fP was added in c-ares 1.7.2
\fBares_set_servers_ports_csv\fP was added in c-ares 1.11.0.
\fBares_get_servers_csv\fP was added in c-ares 1.24.0.
.SH AUTHOR
Ben Greear

View file

@ -31,6 +31,4 @@ abort the ares operation.
.BR ares_set_socket_configure_callback (3)
.SH AVAILABILITY
ares_set_socket_callback(3) was added in c-ares 1.6.0
.SH AUTHOR
Gregor Jasny

View file

@ -31,6 +31,4 @@ abort the ares operation.
.BR ares_set_socket_callback (3)
.SH AVAILABILITY
ares_set_socket_configure_callback(3) was added in c-ares 1.11.0
.SH AUTHOR
Andrew Ayer

View file

@ -99,5 +99,3 @@ Added in c-ares 1.13.0
.BR recvfrom (2),
.BR send (2),
.BR writev (2)
.SH AUTHOR
Carl Wilund

View file

@ -20,7 +20,3 @@ returning the result as a NUL-terminated C string.
.SH NOTES
This function is not compatible with ares, it takes a different set of
arguments.
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.

View file

@ -1,4 +1,5 @@
.\"
.\" Copyright 2023 by the c-ares project and its contributors
.\" SPDX-License-Identifier: MIT
.\"
.TH ARES_THREADSAFETY 3 "26 November 2023"
@ -41,5 +42,3 @@ This function was first introduced in c-ares version 1.23.0.
.BR ares_dup (3),
.BR ares_library_init (3),
.BR ares_set_servers (3)
.SH AUTHOR
Copyright (C) 2023 The c-ares project and its members.

View file

@ -9,7 +9,7 @@ ares_timeout \- return maximum time to wait
.nf
#include <ares.h>
struct timeval *ares_timeout(ares_channel_t *\fIchannel\fP,
struct timeval *ares_timeout(const ares_channel_t *\fIchannel\fP,
struct timeval *\fImaxtv\fP,
struct timeval *\fItv\fP)
.fi
@ -29,7 +29,3 @@ pointed to by \fItv\fP and returns the value of \fItv\fP.
.BR ares_fds (3),
.BR ares_process (3),
.BR ares_process_fd (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.

View file

@ -255,6 +255,7 @@ typedef enum {
#define ARES_OPT_MAXTIMEOUTMS (1 << 20)
#define ARES_OPT_QUERY_CACHE (1 << 21)
#define ARES_OPT_EVENT_THREAD (1 << 22)
#define ARES_OPT_SERVER_FAILOVER (1 << 23)
/* Nameinfo flag values */
#define ARES_NI_NOFQDN (1 << 0)
@ -305,6 +306,9 @@ typedef enum {
#define ARES_LIB_INIT_WIN32 (1 << 0)
#define ARES_LIB_INIT_ALL (ARES_LIB_INIT_WIN32)
/* Server state callback flag values */
#define ARES_SERV_STATE_UDP (1 << 0) /* Query used UDP */
#define ARES_SERV_STATE_TCP (1 << 1) /* Query used TCP */
/*
* Typedef our socket type
@ -326,6 +330,18 @@ typedef void (*ares_sock_state_cb)(void *data, ares_socket_t socket_fd,
struct apattern;
/* Options controlling server failover behavior.
* The retry chance is the probability (1/N) by which we will retry a failed
* server instead of the best server when selecting a server to send queries
* to.
* The retry delay is the minimum time in milliseconds to wait between doing
* such retries (applied per-server).
*/
struct ares_server_failover_options {
unsigned short retry_chance;
size_t retry_delay;
};
/* NOTE about the ares_options struct to users and developers.
This struct will remain looking like this. It will not be extended nor
@ -368,6 +384,7 @@ struct ares_options {
int maxtimeout; /* in milliseconds */
unsigned int qcache_max_ttl; /* Maximum TTL for query cache, 0=disabled */
ares_evsys_t evsys;
struct ares_server_failover_options server_failover_opts;
};
struct hostent;
@ -430,6 +447,10 @@ typedef int (*ares_sock_config_callback)(ares_socket_t socket_fd, int type,
typedef void (*ares_addrinfo_callback)(void *arg, int status, int timeouts,
struct ares_addrinfo *res);
typedef void (*ares_server_state_callback)(const char *server_string,
ares_bool_t success, int flags,
void *data);
CARES_EXTERN int ares_library_init(int flags);
CARES_EXTERN int ares_library_init_mem(int flags, void *(*amalloc)(size_t size),
@ -452,16 +473,16 @@ CARES_EXTERN const char *ares_version(int *version);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_init_options) int ares_init(
ares_channel_t **channelptr);
CARES_EXTERN int ares_init_options(ares_channel_t **channelptr,
const struct ares_options *options,
int optmask);
CARES_EXTERN int ares_init_options(ares_channel_t **channelptr,
const struct ares_options *options,
int optmask);
CARES_EXTERN int ares_save_options(ares_channel_t *channel,
struct ares_options *options, int *optmask);
CARES_EXTERN int ares_save_options(const ares_channel_t *channel,
struct ares_options *options, int *optmask);
CARES_EXTERN void ares_destroy_options(struct ares_options *options);
CARES_EXTERN void ares_destroy_options(struct ares_options *options);
CARES_EXTERN int ares_dup(ares_channel_t **dest, ares_channel_t *src);
CARES_EXTERN int ares_dup(ares_channel_t **dest, const ares_channel_t *src);
CARES_EXTERN ares_status_t ares_reinit(ares_channel_t *channel);
@ -491,6 +512,11 @@ CARES_EXTERN void ares_set_socket_callback(ares_channel_t *ch
CARES_EXTERN void ares_set_socket_configure_callback(
ares_channel_t *channel, ares_sock_config_callback callback, void *user_data);
CARES_EXTERN void
ares_set_server_state_callback(ares_channel_t *channel,
ares_server_state_callback callback,
void *user_data);
CARES_EXTERN int ares_set_sortlist(ares_channel_t *channel,
const char *sortstr);
@ -608,17 +634,17 @@ CARES_EXTERN void ares_getnameinfo(ares_channel_t *channel,
CARES_EXTERN CARES_DEPRECATED_FOR(
ARES_OPT_EVENT_THREAD or
ARES_OPT_SOCK_STATE_CB) int ares_fds(ares_channel_t *channel,
ARES_OPT_SOCK_STATE_CB) int ares_fds(const ares_channel_t *channel,
fd_set *read_fds, fd_set *write_fds);
CARES_EXTERN CARES_DEPRECATED_FOR(
ARES_OPT_EVENT_THREAD or
ARES_OPT_SOCK_STATE_CB) int ares_getsock(ares_channel_t *channel,
ARES_OPT_SOCK_STATE_CB) int ares_getsock(const ares_channel_t *channel,
ares_socket_t *socks, int numsocks);
CARES_EXTERN struct timeval *ares_timeout(ares_channel_t *channel,
struct timeval *maxtv,
struct timeval *tv);
CARES_EXTERN struct timeval *ares_timeout(const ares_channel_t *channel,
struct timeval *maxtv,
struct timeval *tv);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_process_fd) void ares_process(
ares_channel_t *channel, fd_set *read_fds, fd_set *write_fds);
@ -842,22 +868,24 @@ CARES_EXTERN CARES_DEPRECATED_FOR(ares_set_servers_csv) int ares_set_servers(
ares_channel_t *channel, const struct ares_addr_node *servers);
CARES_EXTERN
CARES_DEPRECATED_FOR(ares_set_servers_ports_csv) int ares_set_servers_ports(
ares_channel_t *channel, const struct ares_addr_port_node *servers);
CARES_DEPRECATED_FOR(ares_set_servers_ports_csv)
int ares_set_servers_ports(ares_channel_t *channel,
const struct ares_addr_port_node *servers);
/* Incoming string format: host[:port][,host[:port]]... */
CARES_EXTERN int ares_set_servers_csv(ares_channel_t *channel,
const char *servers);
CARES_EXTERN int ares_set_servers_ports_csv(ares_channel_t *channel,
const char *servers);
CARES_EXTERN char *ares_get_servers_csv(ares_channel_t *channel);
CARES_EXTERN char *ares_get_servers_csv(const ares_channel_t *channel);
CARES_EXTERN CARES_DEPRECATED_FOR(ares_get_servers_csv) int ares_get_servers(
ares_channel_t *channel, struct ares_addr_node **servers);
const ares_channel_t *channel, struct ares_addr_node **servers);
CARES_EXTERN
CARES_DEPRECATED_FOR(ares_get_servers_ports_csv) int ares_get_servers_ports(
ares_channel_t *channel, struct ares_addr_port_node **servers);
CARES_DEPRECATED_FOR(ares_get_servers_ports_csv)
int ares_get_servers_ports(const ares_channel_t *channel,
struct ares_addr_port_node **servers);
CARES_EXTERN const char *ares_inet_ntop(int af, const void *src, char *dst,
ares_socklen_t size);
@ -891,7 +919,7 @@ CARES_EXTERN ares_status_t ares_queue_wait_empty(ares_channel_t *channel,
* \param[in] channel Initialized ares channel
* \return Number of active queries to servers
*/
CARES_EXTERN size_t ares_queue_active_queries(ares_channel_t *channel);
CARES_EXTERN size_t ares_queue_active_queries(const ares_channel_t *channel);
#ifdef __cplusplus
}

View file

@ -31,12 +31,12 @@
#define ARES_COPYRIGHT "2004 - 2024 Daniel Stenberg, <daniel@haxx.se>."
#define ARES_VERSION_MAJOR 1
#define ARES_VERSION_MINOR 28
#define ARES_VERSION_PATCH 1
#define ARES_VERSION_MINOR 29
#define ARES_VERSION_PATCH 0
#define ARES_VERSION \
((ARES_VERSION_MAJOR << 16) | (ARES_VERSION_MINOR << 8) | \
(ARES_VERSION_PATCH))
#define ARES_VERSION_STR "1.28.1"
#define ARES_VERSION_STR "1.29.0"
#if (ARES_VERSION >= 0x010700)
# define CARES_HAVE_ARES_LIBRARY_INIT 1

View file

@ -36,6 +36,10 @@ IF (CARES_SHARED)
C_STANDARD 90
)
IF (ANDROID)
SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES C_STANDARD 99)
ENDIF ()
IF (CARES_SYMBOL_HIDING)
SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES
C_VISIBILITY_PRESET hidden
@ -92,6 +96,10 @@ IF (CARES_STATIC)
C_STANDARD 90
)
IF (ANDROID)
SET_TARGET_PROPERTIES (${LIBNAME} PROPERTIES C_STANDARD 99)
ENDIF ()
IF (CARES_STATIC_PIC)
SET_TARGET_PROPERTIES (${LIBNAME} PROPERTIES POSITION_INDEPENDENT_CODE True)
ENDIF ()

View file

@ -15,7 +15,7 @@
@SET_MAKE@
# aminclude_static.am generated automatically by Autoconf
# from AX_AM_MACROS_STATIC on Sat Mar 30 16:15:43 CET 2024
# from AX_AM_MACROS_STATIC on Fri May 24 08:48:15 CEST 2024
# Copyright (C) The c-ares project and its contributors
# SPDX-License-Identifier: MIT
@ -167,6 +167,7 @@ am__objects_1 = libcares_la-ares__addrinfo2hostent.lo \
libcares_la-ares__htable_asvp.lo \
libcares_la-ares__htable_strvp.lo \
libcares_la-ares__htable_szvp.lo \
libcares_la-ares__htable_vpvp.lo \
libcares_la-ares__iface_ips.lo libcares_la-ares__llist.lo \
libcares_la-ares__parse_into_addrinfo.lo \
libcares_la-ares__slist.lo libcares_la-ares__socket.lo \
@ -176,6 +177,7 @@ am__objects_1 = libcares_la-ares__addrinfo2hostent.lo \
libcares_la-ares_destroy.lo libcares_la-ares_dns_mapping.lo \
libcares_la-ares_dns_name.lo libcares_la-ares_dns_parse.lo \
libcares_la-ares_dns_record.lo libcares_la-ares_dns_write.lo \
libcares_la-ares_event_configchg.lo \
libcares_la-ares_event_epoll.lo \
libcares_la-ares_event_kqueue.lo \
libcares_la-ares_event_poll.lo \
@ -212,9 +214,10 @@ am__objects_1 = libcares_la-ares__addrinfo2hostent.lo \
libcares_la-ares_str.lo libcares_la-ares_strerror.lo \
libcares_la-ares_strsplit.lo libcares_la-ares_sysconfig.lo \
libcares_la-ares_sysconfig_files.lo \
libcares_la-ares_timeout.lo libcares_la-ares_update_servers.lo \
libcares_la-ares_version.lo libcares_la-inet_net_pton.lo \
libcares_la-inet_ntop.lo libcares_la-windows_port.lo
libcares_la-ares_sysconfig_mac.lo libcares_la-ares_timeout.lo \
libcares_la-ares_update_servers.lo libcares_la-ares_version.lo \
libcares_la-inet_net_pton.lo libcares_la-inet_ntop.lo \
libcares_la-windows_port.lo
am__objects_2 =
am_libcares_la_OBJECTS = $(am__objects_1) $(am__objects_2)
libcares_la_OBJECTS = $(am_libcares_la_OBJECTS)
@ -250,6 +253,7 @@ am__depfiles_remade = \
./$(DEPDIR)/libcares_la-ares__htable_asvp.Plo \
./$(DEPDIR)/libcares_la-ares__htable_strvp.Plo \
./$(DEPDIR)/libcares_la-ares__htable_szvp.Plo \
./$(DEPDIR)/libcares_la-ares__htable_vpvp.Plo \
./$(DEPDIR)/libcares_la-ares__iface_ips.Plo \
./$(DEPDIR)/libcares_la-ares__llist.Plo \
./$(DEPDIR)/libcares_la-ares__parse_into_addrinfo.Plo \
@ -268,6 +272,7 @@ am__depfiles_remade = \
./$(DEPDIR)/libcares_la-ares_dns_parse.Plo \
./$(DEPDIR)/libcares_la-ares_dns_record.Plo \
./$(DEPDIR)/libcares_la-ares_dns_write.Plo \
./$(DEPDIR)/libcares_la-ares_event_configchg.Plo \
./$(DEPDIR)/libcares_la-ares_event_epoll.Plo \
./$(DEPDIR)/libcares_la-ares_event_kqueue.Plo \
./$(DEPDIR)/libcares_la-ares_event_poll.Plo \
@ -315,6 +320,7 @@ am__depfiles_remade = \
./$(DEPDIR)/libcares_la-ares_strsplit.Plo \
./$(DEPDIR)/libcares_la-ares_sysconfig.Plo \
./$(DEPDIR)/libcares_la-ares_sysconfig_files.Plo \
./$(DEPDIR)/libcares_la-ares_sysconfig_mac.Plo \
./$(DEPDIR)/libcares_la-ares_timeout.Plo \
./$(DEPDIR)/libcares_la-ares_update_servers.Plo \
./$(DEPDIR)/libcares_la-ares_version.Plo \
@ -623,6 +629,7 @@ CSOURCES = ares__addrinfo2hostent.c \
ares__htable_asvp.c \
ares__htable_strvp.c \
ares__htable_szvp.c \
ares__htable_vpvp.c \
ares__iface_ips.c \
ares__llist.c \
ares__parse_into_addrinfo.c \
@ -640,6 +647,7 @@ CSOURCES = ares__addrinfo2hostent.c \
ares_dns_parse.c \
ares_dns_record.c \
ares_dns_write.c \
ares_event_configchg.c \
ares_event_epoll.c \
ares_event_kqueue.c \
ares_event_poll.c \
@ -688,6 +696,7 @@ CSOURCES = ares__addrinfo2hostent.c \
ares_strsplit.c \
ares_sysconfig.c \
ares_sysconfig_files.c \
ares_sysconfig_mac.c \
ares_timeout.c \
ares_update_servers.c \
ares_version.c \
@ -700,6 +709,7 @@ HHEADERS = ares__buf.h \
ares__htable_asvp.h \
ares__htable_strvp.h \
ares__htable_szvp.h \
ares__htable_vpvp.h \
ares__iface_ips.h \
ares__llist.h \
ares__slist.h \
@ -827,6 +837,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__htable_asvp.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__htable_strvp.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__htable_szvp.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__htable_vpvp.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__iface_ips.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__llist.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__parse_into_addrinfo.Plo@am__quote@ # am--include-marker
@ -845,6 +856,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_dns_parse.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_dns_record.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_dns_write.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_event_configchg.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_event_epoll.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_event_kqueue.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_event_poll.Plo@am__quote@ # am--include-marker
@ -892,6 +904,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_strsplit.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_sysconfig.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_sysconfig_files.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_sysconfig_mac.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_timeout.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_update_servers.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_version.Plo@am__quote@ # am--include-marker
@ -992,6 +1005,13 @@ libcares_la-ares__htable_szvp.lo: ares__htable_szvp.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares__htable_szvp.lo `test -f 'ares__htable_szvp.c' || echo '$(srcdir)/'`ares__htable_szvp.c
libcares_la-ares__htable_vpvp.lo: ares__htable_vpvp.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares__htable_vpvp.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares__htable_vpvp.Tpo -c -o libcares_la-ares__htable_vpvp.lo `test -f 'ares__htable_vpvp.c' || echo '$(srcdir)/'`ares__htable_vpvp.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares__htable_vpvp.Tpo $(DEPDIR)/libcares_la-ares__htable_vpvp.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares__htable_vpvp.c' object='libcares_la-ares__htable_vpvp.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares__htable_vpvp.lo `test -f 'ares__htable_vpvp.c' || echo '$(srcdir)/'`ares__htable_vpvp.c
libcares_la-ares__iface_ips.lo: ares__iface_ips.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares__iface_ips.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares__iface_ips.Tpo -c -o libcares_la-ares__iface_ips.lo `test -f 'ares__iface_ips.c' || echo '$(srcdir)/'`ares__iface_ips.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares__iface_ips.Tpo $(DEPDIR)/libcares_la-ares__iface_ips.Plo
@ -1111,6 +1131,13 @@ libcares_la-ares_dns_write.lo: ares_dns_write.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_dns_write.lo `test -f 'ares_dns_write.c' || echo '$(srcdir)/'`ares_dns_write.c
libcares_la-ares_event_configchg.lo: ares_event_configchg.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_event_configchg.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_event_configchg.Tpo -c -o libcares_la-ares_event_configchg.lo `test -f 'ares_event_configchg.c' || echo '$(srcdir)/'`ares_event_configchg.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_event_configchg.Tpo $(DEPDIR)/libcares_la-ares_event_configchg.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_event_configchg.c' object='libcares_la-ares_event_configchg.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_event_configchg.lo `test -f 'ares_event_configchg.c' || echo '$(srcdir)/'`ares_event_configchg.c
libcares_la-ares_event_epoll.lo: ares_event_epoll.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_event_epoll.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_event_epoll.Tpo -c -o libcares_la-ares_event_epoll.lo `test -f 'ares_event_epoll.c' || echo '$(srcdir)/'`ares_event_epoll.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_event_epoll.Tpo $(DEPDIR)/libcares_la-ares_event_epoll.Plo
@ -1447,6 +1474,13 @@ libcares_la-ares_sysconfig_files.lo: ares_sysconfig_files.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_sysconfig_files.lo `test -f 'ares_sysconfig_files.c' || echo '$(srcdir)/'`ares_sysconfig_files.c
libcares_la-ares_sysconfig_mac.lo: ares_sysconfig_mac.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_sysconfig_mac.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_sysconfig_mac.Tpo -c -o libcares_la-ares_sysconfig_mac.lo `test -f 'ares_sysconfig_mac.c' || echo '$(srcdir)/'`ares_sysconfig_mac.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_sysconfig_mac.Tpo $(DEPDIR)/libcares_la-ares_sysconfig_mac.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_sysconfig_mac.c' object='libcares_la-ares_sysconfig_mac.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_sysconfig_mac.lo `test -f 'ares_sysconfig_mac.c' || echo '$(srcdir)/'`ares_sysconfig_mac.c
libcares_la-ares_timeout.lo: ares_timeout.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_timeout.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_timeout.Tpo -c -o libcares_la-ares_timeout.lo `test -f 'ares_timeout.c' || echo '$(srcdir)/'`ares_timeout.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_timeout.Tpo $(DEPDIR)/libcares_la-ares_timeout.Plo
@ -1705,6 +1739,7 @@ distclean: distclean-recursive
-rm -f ./$(DEPDIR)/libcares_la-ares__htable_asvp.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares__htable_strvp.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares__htable_szvp.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares__htable_vpvp.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares__iface_ips.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares__llist.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares__parse_into_addrinfo.Plo
@ -1723,6 +1758,7 @@ distclean: distclean-recursive
-rm -f ./$(DEPDIR)/libcares_la-ares_dns_parse.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_dns_record.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_dns_write.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_event_configchg.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_event_epoll.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_event_kqueue.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_event_poll.Plo
@ -1770,6 +1806,7 @@ distclean: distclean-recursive
-rm -f ./$(DEPDIR)/libcares_la-ares_strsplit.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_sysconfig.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_sysconfig_files.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_sysconfig_mac.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_timeout.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_update_servers.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_version.Plo
@ -1830,6 +1867,7 @@ maintainer-clean: maintainer-clean-recursive
-rm -f ./$(DEPDIR)/libcares_la-ares__htable_asvp.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares__htable_strvp.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares__htable_szvp.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares__htable_vpvp.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares__iface_ips.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares__llist.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares__parse_into_addrinfo.Plo
@ -1848,6 +1886,7 @@ maintainer-clean: maintainer-clean-recursive
-rm -f ./$(DEPDIR)/libcares_la-ares_dns_parse.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_dns_record.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_dns_write.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_event_configchg.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_event_epoll.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_event_kqueue.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_event_poll.Plo
@ -1895,6 +1934,7 @@ maintainer-clean: maintainer-clean-recursive
-rm -f ./$(DEPDIR)/libcares_la-ares_strsplit.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_sysconfig.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_sysconfig_files.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_sysconfig_mac.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_timeout.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_update_servers.Plo
-rm -f ./$(DEPDIR)/libcares_la-ares_version.Plo

View file

@ -10,6 +10,7 @@ CSOURCES = ares__addrinfo2hostent.c \
ares__htable_asvp.c \
ares__htable_strvp.c \
ares__htable_szvp.c \
ares__htable_vpvp.c \
ares__iface_ips.c \
ares__llist.c \
ares__parse_into_addrinfo.c \
@ -27,6 +28,7 @@ CSOURCES = ares__addrinfo2hostent.c \
ares_dns_parse.c \
ares_dns_record.c \
ares_dns_write.c \
ares_event_configchg.c \
ares_event_epoll.c \
ares_event_kqueue.c \
ares_event_poll.c \
@ -75,6 +77,7 @@ CSOURCES = ares__addrinfo2hostent.c \
ares_strsplit.c \
ares_sysconfig.c \
ares_sysconfig_files.c \
ares_sysconfig_mac.c \
ares_timeout.c \
ares_update_servers.c \
ares_version.c \
@ -87,6 +90,7 @@ HHEADERS = ares__buf.h \
ares__htable_asvp.h \
ares__htable_strvp.h \
ares__htable_szvp.h \
ares__htable_vpvp.h \
ares__iface_ips.h \
ares__llist.h \
ares__slist.h \

View file

@ -97,6 +97,14 @@ void ares__check_cleanup_conn(const ares_channel_t *channel,
do_cleanup = ARES_TRUE;
}
/* If the associated server has failures, close it out. Resetting the
* connection (and specifically the source port number) can help resolve
* situations where packets are being dropped.
*/
if (conn->server->consec_failures > 0) {
do_cleanup = ARES_TRUE;
}
/* If the udp connection hit its max queries, always close it */
if (!conn->is_tcp && channel->udp_max_queries > 0 &&
conn->total_queries >= channel->udp_max_queries) {

195
deps/cares/src/lib/ares__htable_vpvp.c vendored Normal file
View file

@ -0,0 +1,195 @@
/* MIT License
*
* Copyright (c) 2024 Brad House
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* SPDX-License-Identifier: MIT
*/
#include "ares_setup.h"
#include "ares.h"
#include "ares_private.h"
#include "ares__htable.h"
#include "ares__htable_vpvp.h"
struct ares__htable_vpvp {
ares__htable_vpvp_key_free_t free_key;
ares__htable_vpvp_val_free_t free_val;
ares__htable_t *hash;
};
typedef struct {
void *key;
void *val;
ares__htable_vpvp_t *parent;
} ares__htable_vpvp_bucket_t;
void ares__htable_vpvp_destroy(ares__htable_vpvp_t *htable)
{
if (htable == NULL) {
return;
}
ares__htable_destroy(htable->hash);
ares_free(htable);
}
static unsigned int hash_func(const void *key, unsigned int seed)
{
return ares__htable_hash_FNV1a((const unsigned char *)&key, sizeof(key),
seed);
}
static const void *bucket_key(const void *bucket)
{
const ares__htable_vpvp_bucket_t *arg = bucket;
return arg->key;
}
static void bucket_free(void *bucket)
{
ares__htable_vpvp_bucket_t *arg = bucket;
if (arg->parent->free_key) {
arg->parent->free_key(arg->key);
}
if (arg->parent->free_val) {
arg->parent->free_val(arg->val);
}
ares_free(arg);
}
static ares_bool_t key_eq(const void *key1, const void *key2)
{
if (key1 == key2) {
return ARES_TRUE;
}
return ARES_FALSE;
}
ares__htable_vpvp_t *
ares__htable_vpvp_create(ares__htable_vpvp_key_free_t key_free,
ares__htable_vpvp_val_free_t val_free)
{
ares__htable_vpvp_t *htable = ares_malloc(sizeof(*htable));
if (htable == NULL) {
goto fail;
}
htable->hash =
ares__htable_create(hash_func, bucket_key, bucket_free, key_eq);
if (htable->hash == NULL) {
goto fail;
}
htable->free_key = key_free;
htable->free_val = val_free;
return htable;
fail:
if (htable) {
ares__htable_destroy(htable->hash);
ares_free(htable);
}
return NULL;
}
ares_bool_t ares__htable_vpvp_insert(ares__htable_vpvp_t *htable, void *key,
void *val)
{
ares__htable_vpvp_bucket_t *bucket = NULL;
if (htable == NULL) {
goto fail;
}
bucket = ares_malloc(sizeof(*bucket));
if (bucket == NULL) {
goto fail;
}
bucket->parent = htable;
bucket->key = key;
bucket->val = val;
if (!ares__htable_insert(htable->hash, bucket)) {
goto fail;
}
return ARES_TRUE;
fail:
if (bucket) {
ares_free(bucket);
}
return ARES_FALSE;
}
ares_bool_t ares__htable_vpvp_get(const ares__htable_vpvp_t *htable, void *key,
void **val)
{
ares__htable_vpvp_bucket_t *bucket = NULL;
if (val) {
*val = NULL;
}
if (htable == NULL) {
return ARES_FALSE;
}
bucket = ares__htable_get(htable->hash, key);
if (bucket == NULL) {
return ARES_FALSE;
}
if (val) {
*val = bucket->val;
}
return ARES_TRUE;
}
void *ares__htable_vpvp_get_direct(const ares__htable_vpvp_t *htable, void *key)
{
void *val = NULL;
ares__htable_vpvp_get(htable, key, &val);
return val;
}
ares_bool_t ares__htable_vpvp_remove(ares__htable_vpvp_t *htable, void *key)
{
if (htable == NULL) {
return ARES_FALSE;
}
return ares__htable_remove(htable->hash, key);
}
size_t ares__htable_vpvp_num_keys(const ares__htable_vpvp_t *htable)
{
if (htable == NULL) {
return 0;
}
return ares__htable_num_keys(htable->hash);
}

127
deps/cares/src/lib/ares__htable_vpvp.h vendored Normal file
View file

@ -0,0 +1,127 @@
/* MIT License
*
* Copyright (c) 2024 Brad House
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* SPDX-License-Identifier: MIT
*/
#ifndef __ARES__HTABLE_VPVP_H
#define __ARES__HTABLE_VPVP_H
/*! \addtogroup ares__htable_vpvp HashTable with void pointer Key and void
* pointer Value
*
* This data structure wraps the base ares__htable data structure in order to
* split the key and value data types as size_t and void pointer, respectively.
*
* Average time complexity:
* - Insert: O(1)
* - Search: O(1)
* - Delete: O(1)
*
* @{
*/
struct ares__htable_vpvp;
/*! Opaque data type for size_t key, void pointer hash table implementation */
typedef struct ares__htable_vpvp ares__htable_vpvp_t;
/*! Callback to free key stored in hashtable
*
* \param[in] key user-supplied key
*/
typedef void (*ares__htable_vpvp_key_free_t)(void *key);
/*! Callback to free value stored in hashtable
*
* \param[in] val user-supplied value
*/
typedef void (*ares__htable_vpvp_val_free_t)(void *val);
/*! Destroy hashtable
*
* \param[in] htable Initialized hashtable
*/
void ares__htable_vpvp_destroy(ares__htable_vpvp_t *htable);
/*! Create size_t key, void pointer value hash table
*
* \param[in] key_free Optional. Call back to free user-supplied key. If
* NULL it is expected the caller will clean up any user
* supplied keys.
* \param[in] val_free Optional. Call back to free user-supplied value. If
* NULL it is expected the caller will clean up any user
* supplied values.
*/
ares__htable_vpvp_t *
ares__htable_vpvp_create(ares__htable_vpvp_key_free_t key_free,
ares__htable_vpvp_val_free_t val_free);
/*! Insert key/value into hash table
*
* \param[in] htable Initialized hash table
* \param[in] key key to associate with value
* \param[in] val value to store (takes ownership). May be NULL.
* \return ARES_TRUE on success, ARES_FALSE on failure or out of memory
*/
ares_bool_t ares__htable_vpvp_insert(ares__htable_vpvp_t *htable, void *key,
void *val);
/*! Retrieve value from hashtable based on key
*
* \param[in] htable Initialized hash table
* \param[in] key key to use to search
* \param[out] val Optional. Pointer to store value.
* \return ARES_TRUE on success, ARES_FALSE on failure
*/
ares_bool_t ares__htable_vpvp_get(const ares__htable_vpvp_t *htable, void *key,
void **val);
/*! Retrieve value from hashtable directly as return value. Caveat to this
* function over ares__htable_vpvp_get() is that if a NULL value is stored
* you cannot determine if the key is not found or the value is NULL.
*
* \param[in] htable Initialized hash table
* \param[in] key key to use to search
* \return value associated with key in hashtable or NULL
*/
void *ares__htable_vpvp_get_direct(const ares__htable_vpvp_t *htable,
void *key);
/*! Remove a value from the hashtable by key
*
* \param[in] htable Initialized hash table
* \param[in] key key to use to search
* \return ARES_TRUE if found, ARES_FALSE if not
*/
ares_bool_t ares__htable_vpvp_remove(ares__htable_vpvp_t *htable, void *key);
/*! Retrieve the number of keys stored in the hash table
*
* \param[in] htable Initialized hash table
* \return count
*/
size_t ares__htable_vpvp_num_keys(const ares__htable_vpvp_t *htable);
/*! @} */
#endif /* __ARES__HTABLE_VPVP_H */

View file

@ -253,12 +253,6 @@ ares_status_t ares__open_connection(ares_channel_t *channel,
struct server_connection *conn;
ares__llist_node_t *node;
int type = is_tcp ? SOCK_STREAM : SOCK_DGRAM;
#ifdef __OpenBSD__
if ((is_tcp && server->tcp_port == 53) ||
(!is_tcp && server->udp_port == 53)) {
type |= SOCK_DNS;
}
#endif
switch (server->addr.family) {
case AF_INET:

View file

@ -537,12 +537,12 @@ void ares__channel_threading_destroy(ares_channel_t *channel)
channel->cond_empty = NULL;
}
void ares__channel_lock(ares_channel_t *channel)
void ares__channel_lock(const ares_channel_t *channel)
{
ares__thread_mutex_lock(channel->lock);
}
void ares__channel_unlock(ares_channel_t *channel)
void ares__channel_unlock(const ares_channel_t *channel)
{
ares__thread_mutex_unlock(channel->lock);
}
@ -585,6 +585,12 @@ ares_status_t ares_queue_wait_empty(ares_channel_t *channel, int timeout_ms)
status =
ares__thread_cond_timedwait(channel->cond_empty, channel->lock, tms);
}
/* If there was a timeout, don't loop. Otherwise, make sure this wasn't
* a spurious wakeup by looping and checking the condition. */
if (status == ARES_ETIMEOUT) {
break;
}
}
}
ares__thread_mutex_unlock(channel->lock);

View file

@ -31,6 +31,7 @@
#include "ares.h"
#include "ares_private.h"
#include "ares_event.h"
void ares_destroy(ares_channel_t *channel)
{
@ -41,6 +42,22 @@ void ares_destroy(ares_channel_t *channel)
return;
}
/* Disable configuration change monitoring */
if (channel->optmask & ARES_OPT_EVENT_THREAD) {
ares_event_thread_t *e = channel->sock_state_cb_data;
if (e && e->configchg) {
ares_event_configchg_destroy(e->configchg);
e->configchg = NULL;
}
}
/* Wait for reinit thread to exit if there was one pending */
if (channel->reinit_thread != NULL) {
void *rv;
ares__thread_join(channel->reinit_thread, &rv);
channel->reinit_thread = NULL;
}
/* Lock because callbacks will be triggered */
ares__channel_lock(channel);

View file

@ -606,12 +606,12 @@ ares_bool_t ares_dns_class_fromstr(ares_dns_class_t *qclass, const char *str)
const char *name;
ares_dns_class_t qclass;
} list[] = {
{"IN", ARES_CLASS_IN },
{ "CH", ARES_CLASS_CHAOS },
{ "HS", ARES_CLASS_HESOID},
{ "NONE", ARES_CLASS_NONE },
{ "ANY", ARES_CLASS_ANY },
{ NULL, 0 }
{ "IN", ARES_CLASS_IN },
{ "CH", ARES_CLASS_CHAOS },
{ "HS", ARES_CLASS_HESOID },
{ "NONE", ARES_CLASS_NONE },
{ "ANY", ARES_CLASS_ANY },
{ NULL, 0 }
};
if (qclass == NULL || str == NULL) {
@ -636,26 +636,26 @@ ares_bool_t ares_dns_rec_type_fromstr(ares_dns_rec_type_t *qtype,
const char *name;
ares_dns_rec_type_t type;
} list[] = {
{"A", ARES_REC_TYPE_A },
{ "NS", ARES_REC_TYPE_NS },
{ "CNAME", ARES_REC_TYPE_CNAME },
{ "SOA", ARES_REC_TYPE_SOA },
{ "PTR", ARES_REC_TYPE_PTR },
{ "HINFO", ARES_REC_TYPE_HINFO },
{ "MX", ARES_REC_TYPE_MX },
{ "TXT", ARES_REC_TYPE_TXT },
{ "AAAA", ARES_REC_TYPE_AAAA },
{ "SRV", ARES_REC_TYPE_SRV },
{ "NAPTR", ARES_REC_TYPE_NAPTR },
{ "OPT", ARES_REC_TYPE_OPT },
{ "TLSA", ARES_REC_TYPE_TLSA },
{ "SVCB", ARES_REC_TYPE_SVCB },
{ "HTTPS", ARES_REC_TYPE_HTTPS },
{ "ANY", ARES_REC_TYPE_ANY },
{ "URI", ARES_REC_TYPE_URI },
{ "CAA", ARES_REC_TYPE_CAA },
{ "RAW_RR", ARES_REC_TYPE_RAW_RR},
{ NULL, 0 }
{ "A", ARES_REC_TYPE_A },
{ "NS", ARES_REC_TYPE_NS },
{ "CNAME", ARES_REC_TYPE_CNAME },
{ "SOA", ARES_REC_TYPE_SOA },
{ "PTR", ARES_REC_TYPE_PTR },
{ "HINFO", ARES_REC_TYPE_HINFO },
{ "MX", ARES_REC_TYPE_MX },
{ "TXT", ARES_REC_TYPE_TXT },
{ "AAAA", ARES_REC_TYPE_AAAA },
{ "SRV", ARES_REC_TYPE_SRV },
{ "NAPTR", ARES_REC_TYPE_NAPTR },
{ "OPT", ARES_REC_TYPE_OPT },
{ "TLSA", ARES_REC_TYPE_TLSA },
{ "SVCB", ARES_REC_TYPE_SVCB },
{ "HTTPS", ARES_REC_TYPE_HTTPS },
{ "ANY", ARES_REC_TYPE_ANY },
{ "URI", ARES_REC_TYPE_URI },
{ "CAA", ARES_REC_TYPE_CAA },
{ "RAW_RR", ARES_REC_TYPE_RAW_RR },
{ NULL, 0 }
};
if (qtype == NULL || str == NULL) {

View file

@ -362,6 +362,7 @@ ares_status_t ares__dns_name_write(ares__buf_t *buf, ares__llist_t **list,
{
const ares_nameoffset_t *off = NULL;
size_t name_len;
size_t orig_name_len;
size_t pos = ares__buf_len(buf);
ares_dns_labels_t labels;
char name_copy[512];
@ -375,7 +376,8 @@ ares_status_t ares__dns_name_write(ares__buf_t *buf, ares__llist_t **list,
/* NOTE: due to possible escaping, name_copy buffer is > 256 to allow for
* this */
name_len = ares_strcpy(name_copy, name, sizeof(name_copy));
name_len = ares_strcpy(name_copy, name, sizeof(name_copy));
orig_name_len = name_len;
/* Find longest match */
if (list != NULL) {
@ -388,7 +390,7 @@ ares_status_t ares__dns_name_write(ares__buf_t *buf, ares__llist_t **list,
}
/* Output labels */
if (off == NULL || off->name_len != name_len) {
if (off == NULL || off->name_len != orig_name_len) {
size_t i;
status = ares_split_dns_name(&labels, validate_hostname, name_copy);
@ -432,7 +434,7 @@ ares_status_t ares__dns_name_write(ares__buf_t *buf, ares__llist_t **list,
/* Store pointer for future jumps as long as its not an exact match for
* a prior entry */
if (list != NULL && (off == NULL || off->name_len != name_len) &&
if (list != NULL && (off == NULL || off->name_len != orig_name_len) &&
name_len > 0) {
status = ares__nameoffset_create(list, name /* not truncated copy! */, pos);
if (status != ARES_SUCCESS) {

View file

@ -79,6 +79,14 @@ typedef struct {
size_t (*wait)(ares_event_thread_t *e, unsigned long timeout_ms);
} ares_event_sys_t;
struct ares_event_configchg;
typedef struct ares_event_configchg ares_event_configchg_t;
ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg,
ares_event_thread_t *e);
void ares_event_configchg_destroy(ares_event_configchg_t *configchg);
struct ares_event_thread {
/*! Whether the event thread should be online or not. Checked on every wake
* event before sleeping. */
@ -94,13 +102,18 @@ struct ares_event_thread {
* thread other than the event thread itself. The event thread will then
* be woken then process these updates itself */
ares__llist_t *ev_updates;
/*! Registered event handles. */
ares__htable_asvp_t *ev_handles;
/*! Registered socket event handles */
ares__htable_asvp_t *ev_sock_handles;
/*! Registered custom event handles. Typically used for external triggering.
*/
ares__htable_vpvp_t *ev_cust_handles;
/*! Pointer to the event handle which is used to signal and wake the event
* thread itself. This is needed to be able to do things like update the
* file descriptors being waited on and to wake the event subsystem during
* shutdown */
ares_event_t *ev_signal;
/*! Handle for configuration change monitoring */
ares_event_configchg_t *configchg;
/* Event subsystem callbacks */
const ares_event_sys_t *ev_sys;
/* Event subsystem private data */
@ -124,7 +137,8 @@ struct ares_event_thread {
* Non-socket events cannot be removed, and must have
* ARES_EVENT_FLAG_OTHER set.
* \param[in] cb Callback to call when
* event is triggered. Required. Not allowed to be
* event is triggered. Required if flags is not
* ARES_EVENT_FLAG_NONE. Not allowed to be
* changed, ignored on modification.
* \param[in] fd File descriptor/socket to monitor. May
* be ARES_SOCKET_BAD if not monitoring file

View file

@ -0,0 +1,565 @@
/* MIT License
*
* Copyright (c) 2024 Brad House
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* SPDX-License-Identifier: MIT
*/
#include "ares_setup.h"
#include "ares.h"
#include "ares_private.h"
#include "ares_event.h"
static void ares_event_configchg_reload(ares_event_thread_t *e)
{
ares_reinit(e->channel);
}
#ifdef __linux__
# include <sys/inotify.h>
struct ares_event_configchg {
int inotify_fd;
ares_event_thread_t *e;
};
void ares_event_configchg_destroy(ares_event_configchg_t *configchg)
{
if (configchg == NULL) {
return;
}
/* Tell event system to stop monitoring for changes. This will cause the
* cleanup to be called */
ares_event_update(NULL, configchg->e, ARES_EVENT_FLAG_NONE, NULL,
configchg->inotify_fd, NULL, NULL, NULL);
}
static void ares_event_configchg_free(void *data)
{
ares_event_configchg_t *configchg = data;
if (configchg == NULL) {
return;
}
if (configchg->inotify_fd >= 0) {
close(configchg->inotify_fd);
configchg->inotify_fd = -1;
}
ares_free(configchg);
}
static void ares_event_configchg_cb(ares_event_thread_t *e, ares_socket_t fd,
void *data, ares_event_flags_t flags)
{
ares_event_configchg_t *configchg = data;
/* Some systems cannot read integer variables if they are not
* properly aligned. On other systems, incorrect alignment may
* decrease performance. Hence, the buffer used for reading from
* the inotify file descriptor should have the same alignment as
* struct inotify_event. */
unsigned char buf[4096]
__attribute__((aligned(__alignof__(struct inotify_event))));
const struct inotify_event *event;
ssize_t len;
ares_bool_t triggered = ARES_FALSE;
(void)fd;
(void)flags;
while (1) {
const unsigned char *ptr;
len = read(configchg->inotify_fd, buf, sizeof(buf));
if (len <= 0) {
break;
}
/* Loop over all events in the buffer. Says kernel will check the buffer
* size provided, so I assume it won't ever return partial events. */
for (ptr = buf; ptr < buf + len;
ptr += sizeof(struct inotify_event) + event->len) {
event = (const struct inotify_event *)ptr;
if (event->len == 0 || ares_strlen(event->name) == 0) {
continue;
}
if (strcasecmp(event->name, "resolv.conf") == 0 ||
strcasecmp(event->name, "nsswitch.conf") == 0) {
triggered = ARES_TRUE;
}
}
}
/* Only process after all events are read. No need to process more often as
* we don't want to reload the config back to back */
if (triggered) {
ares_event_configchg_reload(e);
}
}
ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg,
ares_event_thread_t *e)
{
ares_status_t status = ARES_SUCCESS;
ares_event_configchg_t *c;
(void)e;
/* Not used by this implementation */
*configchg = NULL;
c = ares_malloc_zero(sizeof(*c));
if (c == NULL) {
return ARES_ENOMEM;
}
c->e = e;
c->inotify_fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
if (c->inotify_fd == -1) {
status = ARES_ESERVFAIL;
goto done;
}
/* We need to monitor /etc/resolv.conf, /etc/nsswitch.conf */
if (inotify_add_watch(c->inotify_fd, "/etc",
IN_CREATE | IN_MODIFY | IN_MOVED_TO | IN_ONLYDIR) ==
-1) {
status = ARES_ESERVFAIL;
goto done;
}
status =
ares_event_update(NULL, e, ARES_EVENT_FLAG_READ, ares_event_configchg_cb,
c->inotify_fd, c, ares_event_configchg_free, NULL);
done:
if (status != ARES_SUCCESS) {
ares_event_configchg_free(c);
}
return status;
}
#elif defined(_WIN32)
# include <winsock2.h>
# include <iphlpapi.h>
# include <stdio.h>
# include <windows.h>
struct ares_event_configchg {
HANDLE ifchg_hnd;
ares_event_thread_t *e;
};
void ares_event_configchg_destroy(ares_event_configchg_t *configchg)
{
# ifdef __WATCOMC__
/* Not supported */
# else
if (configchg == NULL) {
return;
}
if (configchg->ifchg_hnd != NULL) {
CancelMibChangeNotify2(configchg->ifchg_hnd);
configchg->ifchg_hnd = NULL;
}
ares_free(configchg);
# endif
}
# ifndef __WATCOMC__
static void ares_event_configchg_cb(PVOID CallerContext,
PMIB_IPINTERFACE_ROW Row,
MIB_NOTIFICATION_TYPE NotificationType)
{
ares_event_configchg_t *configchg = CallerContext;
(void)Row;
(void)NotificationType;
ares_event_configchg_reload(configchg->e);
}
# endif
ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg,
ares_event_thread_t *e)
{
# ifdef __WATCOMC__
return ARES_ENOTIMP;
# else
ares_status_t status = ARES_SUCCESS;
*configchg = ares_malloc_zero(sizeof(**configchg));
if (*configchg == NULL) {
return ARES_ENOMEM;
}
(*configchg)->e = e;
/* NOTE: If a user goes into the control panel and changes the network
* adapter DNS addresses manually, this will NOT trigger a notification.
* We've also tried listening on NotifyUnicastIpAddressChange(), but
* that didn't get triggered either.
*/
if (NotifyIpInterfaceChange(
AF_UNSPEC, (PIPINTERFACE_CHANGE_CALLBACK)ares_event_configchg_cb,
*configchg, FALSE, &(*configchg)->ifchg_hnd) != NO_ERROR) {
status = ARES_ESERVFAIL;
goto done;
}
done:
if (status != ARES_SUCCESS) {
ares_event_configchg_destroy(*configchg);
*configchg = NULL;
}
return status;
# endif
}
#elif defined(__APPLE__)
# include <sys/types.h>
# include <unistd.h>
# include <notify.h>
# include <dlfcn.h>
struct ares_event_configchg {
int fd;
int token;
};
void ares_event_configchg_destroy(ares_event_configchg_t *configchg)
{
(void)configchg;
/* Cleanup happens automatically */
}
static void ares_event_configchg_free(void *data)
{
ares_event_configchg_t *configchg = data;
if (configchg == NULL) {
return;
}
if (configchg->fd >= 0) {
notify_cancel(configchg->token);
/* automatically closes fd */
configchg->fd = -1;
}
ares_free(configchg);
}
static void ares_event_configchg_cb(ares_event_thread_t *e, ares_socket_t fd,
void *data, ares_event_flags_t flags)
{
ares_event_configchg_t *configchg = data;
ares_bool_t triggered = ARES_FALSE;
(void)fd;
(void)flags;
while (1) {
int t = 0;
ssize_t len;
len = read(configchg->fd, &t, sizeof(t));
if (len < (ssize_t)sizeof(t)) {
break;
}
/* Token is read in network byte order (yeah, docs don't mention this) */
t = (int)ntohl(t);
if (t != configchg->token) {
continue;
}
triggered = ARES_TRUE;
}
/* Only process after all events are read. No need to process more often as
* we don't want to reload the config back to back */
if (triggered) {
ares_event_configchg_reload(e);
}
}
ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg,
ares_event_thread_t *e)
{
ares_status_t status = ARES_SUCCESS;
void *handle = NULL;
const char *(*pdns_configuration_notify_key)(void) = NULL;
const char *notify_key = NULL;
int flags;
*configchg = ares_malloc_zero(sizeof(**configchg));
if (*configchg == NULL) {
return ARES_ENOMEM;
}
/* Load symbol as it isn't normally public */
handle = dlopen("/usr/lib/libSystem.dylib", RTLD_LAZY | RTLD_NOLOAD);
if (handle == NULL) {
status = ARES_ESERVFAIL;
goto done;
}
pdns_configuration_notify_key = dlsym(handle, "dns_configuration_notify_key");
if (pdns_configuration_notify_key == NULL) {
status = ARES_ESERVFAIL;
goto done;
}
notify_key = pdns_configuration_notify_key();
if (notify_key == NULL) {
status = ARES_ESERVFAIL;
goto done;
}
if (notify_register_file_descriptor(notify_key, &(*configchg)->fd, 0,
&(*configchg)->token) !=
NOTIFY_STATUS_OK) {
status = ARES_ESERVFAIL;
goto done;
}
/* Set file descriptor to non-blocking */
flags = fcntl((*configchg)->fd, F_GETFL, 0);
fcntl((*configchg)->fd, F_SETFL, flags | O_NONBLOCK);
/* Register file descriptor with event subsystem */
status = ares_event_update(NULL, e, ARES_EVENT_FLAG_READ,
ares_event_configchg_cb, (*configchg)->fd,
*configchg, ares_event_configchg_free, NULL);
done:
if (status != ARES_SUCCESS) {
ares_event_configchg_free(*configchg);
*configchg = NULL;
}
if (handle) {
dlclose(handle);
}
return status;
}
#elif defined(HAVE_STAT)
# ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
# endif
# ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
# endif
typedef struct {
size_t size;
time_t mtime;
} fileinfo_t;
struct ares_event_configchg {
ares_bool_t isup;
ares__thread_t *thread;
ares__htable_strvp_t *filestat;
ares__thread_mutex_t *lock;
ares__thread_cond_t *wake;
const char *resolvconf_path;
ares_event_thread_t *e;
};
static ares_status_t config_change_check(ares__htable_strvp_t *filestat,
const char *resolvconf_path)
{
size_t i;
const char *configfiles[] = { resolvconf_path, "/etc/nsswitch.conf",
"/etc/netsvc.conf", "/etc/svc.conf", NULL };
ares_bool_t changed = ARES_FALSE;
for (i = 0; configfiles[i] != NULL; i++) {
fileinfo_t *fi = ares__htable_strvp_get_direct(filestat, configfiles[i]);
struct stat st;
if (stat(configfiles[i], &st) == 0) {
if (fi == NULL) {
fi = ares_malloc_zero(sizeof(*fi));
if (fi == NULL) {
return ARES_ENOMEM;
}
if (!ares__htable_strvp_insert(filestat, configfiles[i], fi)) {
ares_free(fi);
return ARES_ENOMEM;
}
}
if (fi->size != (size_t)st.st_size || fi->mtime != (time_t)st.st_mtime) {
changed = ARES_TRUE;
}
fi->size = (size_t)st.st_size;
fi->mtime = (time_t)st.st_mtime;
} else if (fi != NULL) {
/* File no longer exists, remove */
ares__htable_strvp_remove(filestat, configfiles[i]);
changed = ARES_TRUE;
}
}
if (changed) {
return ARES_SUCCESS;
}
return ARES_ENOTFOUND;
}
static void *ares_event_configchg_thread(void *arg)
{
ares_event_configchg_t *c = arg;
ares__thread_mutex_lock(c->lock);
while (c->isup) {
ares_status_t status;
if (ares__thread_cond_timedwait(c->wake, c->lock, 30000) != ARES_ETIMEOUT) {
continue;
}
/* make sure status didn't change even though we got a timeout */
if (!c->isup) {
break;
}
status = config_change_check(c->filestat, c->resolvconf_path);
if (status == ARES_SUCCESS) {
ares_event_configchg_reload(c->e);
}
}
ares__thread_mutex_unlock(c->lock);
return NULL;
}
ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg,
ares_event_thread_t *e)
{
ares_status_t status = ARES_SUCCESS;
ares_event_configchg_t *c = NULL;
*configchg = NULL;
c = ares_malloc_zero(sizeof(*c));
if (c == NULL) {
status = ARES_ENOMEM;
goto done;
}
c->e = e;
c->filestat = ares__htable_strvp_create(ares_free);
if (c->filestat == NULL) {
status = ARES_ENOMEM;
goto done;
}
c->wake = ares__thread_cond_create();
if (c->wake == NULL) {
status = ARES_ENOMEM;
goto done;
}
c->resolvconf_path = c->e->channel->resolvconf_path;
if (c->resolvconf_path == NULL) {
c->resolvconf_path = PATH_RESOLV_CONF;
}
status = config_change_check(c->filestat, c->resolvconf_path);
if (status == ARES_ENOMEM) {
goto done;
}
c->isup = ARES_TRUE;
status = ares__thread_create(&c->thread, ares_event_configchg_thread, c);
done:
if (status != ARES_SUCCESS) {
ares_event_configchg_destroy(c);
} else {
*configchg = c;
}
return status;
}
void ares_event_configchg_destroy(ares_event_configchg_t *configchg)
{
if (configchg == NULL) {
return;
}
if (configchg->lock) {
ares__thread_mutex_lock(configchg->lock);
}
configchg->isup = ARES_FALSE;
if (configchg->wake) {
ares__thread_cond_signal(configchg->wake);
}
if (configchg->lock) {
ares__thread_mutex_unlock(configchg->lock);
}
if (configchg->thread) {
void *rv = NULL;
ares__thread_join(configchg->thread, &rv);
}
ares__thread_mutex_destroy(configchg->lock);
ares__thread_cond_destroy(configchg->wake);
ares__htable_strvp_destroy(configchg->filestat);
ares_free(configchg);
}
#else
ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg,
ares_event_thread_t *e)
{
/* No ability */
return ARES_ENOTIMP;
}
void ares_event_configchg_destroy(ares_event_configchg_t *configchg)
{
/* No-op */
}
#endif

View file

@ -167,7 +167,7 @@ static size_t ares_evsys_epoll_wait(ares_event_thread_t *e,
ares_event_t *ev;
ares_event_flags_t flags = 0;
ev = ares__htable_asvp_get_direct(e->ev_handles,
ev = ares__htable_asvp_get_direct(e->ev_sock_handles,
(ares_socket_t)events[i].data.fd);
if (ev == NULL || ev->cb == NULL) {
continue;

View file

@ -218,7 +218,7 @@ static size_t ares_evsys_kqueue_wait(ares_event_thread_t *e,
ares_event_t *ev;
ares_event_flags_t flags = 0;
ev = ares__htable_asvp_get_direct(e->ev_handles,
ev = ares__htable_asvp_get_direct(e->ev_sock_handles,
(ares_socket_t)events[i].ident);
if (ev == NULL || ev->cb == NULL) {
continue;

View file

@ -69,7 +69,7 @@ static size_t ares_evsys_poll_wait(ares_event_thread_t *e,
unsigned long timeout_ms)
{
size_t num_fds = 0;
ares_socket_t *fdlist = ares__htable_asvp_keys(e->ev_handles, &num_fds);
ares_socket_t *fdlist = ares__htable_asvp_keys(e->ev_sock_handles, &num_fds);
struct pollfd *pollfd = NULL;
int rv;
size_t cnt = 0;
@ -82,7 +82,7 @@ static size_t ares_evsys_poll_wait(ares_event_thread_t *e,
}
for (i = 0; i < num_fds; i++) {
const ares_event_t *ev =
ares__htable_asvp_get_direct(e->ev_handles, fdlist[i]);
ares__htable_asvp_get_direct(e->ev_sock_handles, fdlist[i]);
pollfd[i].fd = ev->fd;
if (ev->flags & ARES_EVENT_FLAG_READ) {
pollfd[i].events |= POLLIN;
@ -109,7 +109,7 @@ static size_t ares_evsys_poll_wait(ares_event_thread_t *e,
cnt++;
ev = ares__htable_asvp_get_direct(e->ev_handles, pollfd[i].fd);
ev = ares__htable_asvp_get_direct(e->ev_sock_handles, pollfd[i].fd);
if (ev == NULL || ev->cb == NULL) {
continue;
}

View file

@ -23,6 +23,12 @@
*
* SPDX-License-Identifier: MIT
*/
/* Some systems might default to something low like 256 (NetBSD), lets define
* this to assist. Really, no one should be using select, but lets be safe
* anyhow */
#define FD_SETSIZE 4096
#include "ares_setup.h"
#include "ares.h"
#include "ares_private.h"
@ -71,7 +77,7 @@ static size_t ares_evsys_select_wait(ares_event_thread_t *e,
unsigned long timeout_ms)
{
size_t num_fds = 0;
ares_socket_t *fdlist = ares__htable_asvp_keys(e->ev_handles, &num_fds);
ares_socket_t *fdlist = ares__htable_asvp_keys(e->ev_sock_handles, &num_fds);
int rv;
size_t cnt = 0;
size_t i;
@ -86,7 +92,7 @@ static size_t ares_evsys_select_wait(ares_event_thread_t *e,
for (i = 0; i < num_fds; i++) {
const ares_event_t *ev =
ares__htable_asvp_get_direct(e->ev_handles, fdlist[i]);
ares__htable_asvp_get_direct(e->ev_sock_handles, fdlist[i]);
if (ev->flags & ARES_EVENT_FLAG_READ) {
FD_SET(ev->fd, &read_fds);
}
@ -110,7 +116,7 @@ static size_t ares_evsys_select_wait(ares_event_thread_t *e,
ares_event_t *ev;
ares_event_flags_t flags = 0;
ev = ares__htable_asvp_get_direct(e->ev_handles, fdlist[i]);
ev = ares__htable_asvp_get_direct(e->ev_sock_handles, fdlist[i]);
if (ev == NULL || ev->cb == NULL) {
continue;
}

View file

@ -89,7 +89,12 @@ ares_status_t ares_event_update(ares_event_t **event, ares_event_thread_t *e,
{
ares_event_t *ev = NULL;
if (e == NULL || cb == NULL) {
if (e == NULL) {
return ARES_EFORMERR;
}
/* Callback must be specified if not a removal event. */
if (flags != ARES_EVENT_FLAG_NONE && cb == NULL) {
return ARES_EFORMERR;
}
@ -211,8 +216,13 @@ static void ares_event_process_updates(ares_event_thread_t *e)
* list */
while ((node = ares__llist_node_first(e->ev_updates)) != NULL) {
ares_event_t *newev = ares__llist_node_claim(node);
ares_event_t *oldev =
ares__htable_asvp_get_direct(e->ev_handles, newev->fd);
ares_event_t *oldev;
if (newev->fd == ARES_SOCKET_BAD) {
oldev = ares__htable_vpvp_get_direct(e->ev_cust_handles, newev->data);
} else {
oldev = ares__htable_asvp_get_direct(e->ev_sock_handles, newev->fd);
}
/* Adding new */
if (oldev == NULL) {
@ -225,7 +235,11 @@ static void ares_event_process_updates(ares_event_thread_t *e)
newev->e = NULL;
ares_event_destroy_cb(newev);
} else {
ares__htable_asvp_insert(e->ev_handles, newev->fd, newev);
if (newev->fd == ARES_SOCKET_BAD) {
ares__htable_vpvp_insert(e->ev_cust_handles, newev->data, newev);
} else {
ares__htable_asvp_insert(e->ev_sock_handles, newev->fd, newev);
}
}
continue;
}
@ -234,7 +248,11 @@ static void ares_event_process_updates(ares_event_thread_t *e)
if (newev->flags == ARES_EVENT_FLAG_NONE) {
/* the callback for the removal will call e->ev_sys->event_del(e, event)
*/
ares__htable_asvp_remove(e->ev_handles, newev->fd);
if (newev->fd == ARES_SOCKET_BAD) {
ares__htable_vpvp_remove(e->ev_cust_handles, newev->data);
} else {
ares__htable_asvp_remove(e->ev_sock_handles, newev->fd);
}
ares_free(newev);
continue;
}
@ -306,10 +324,13 @@ static void ares_event_thread_destroy_int(ares_event_thread_t *e)
ares__llist_destroy(e->ev_updates);
e->ev_updates = NULL;
ares__htable_asvp_destroy(e->ev_handles);
e->ev_handles = NULL;
ares__htable_asvp_destroy(e->ev_sock_handles);
e->ev_sock_handles = NULL;
if (e->ev_sys->destroy) {
ares__htable_vpvp_destroy(e->ev_cust_handles);
e->ev_cust_handles = NULL;
if (e->ev_sys && e->ev_sys->destroy) {
e->ev_sys->destroy(e);
}
@ -409,8 +430,14 @@ ares_status_t ares_event_thread_init(ares_channel_t *channel)
return ARES_ENOMEM;
}
e->ev_handles = ares__htable_asvp_create(ares_event_destroy_cb);
if (e->ev_handles == NULL) {
e->ev_sock_handles = ares__htable_asvp_create(ares_event_destroy_cb);
if (e->ev_sock_handles == NULL) {
ares_event_thread_destroy_int(e);
return ARES_ENOMEM;
}
e->ev_cust_handles = ares__htable_vpvp_create(NULL, ares_event_destroy_cb);
if (e->ev_cust_handles == NULL) {
ares_event_thread_destroy_int(e);
return ARES_ENOMEM;
}

View file

@ -30,7 +30,7 @@
#include "ares.h"
#include "ares_private.h"
int ares_fds(ares_channel_t *channel, fd_set *read_fds, fd_set *write_fds)
int ares_fds(const ares_channel_t *channel, fd_set *read_fds, fd_set *write_fds)
{
ares_socket_t nfds;
ares__slist_node_t *snode;

View file

@ -98,11 +98,12 @@ static void ares_getnameinfo_int(ares_channel_t *channel,
unsigned int flags = (unsigned int)flags_int;
/* Validate socket address family and length */
if ((sa->sa_family == AF_INET) && (salen == sizeof(struct sockaddr_in))) {
if (sa && sa->sa_family == AF_INET &&
salen >= (ares_socklen_t)sizeof(struct sockaddr_in)) {
addr = CARES_INADDR_CAST(struct sockaddr_in *, sa);
port = addr->sin_port;
} else if ((sa->sa_family == AF_INET6) &&
(salen == sizeof(struct sockaddr_in6))) {
} else if (sa && sa->sa_family == AF_INET6 &&
salen >= (ares_socklen_t)sizeof(struct sockaddr_in6)) {
addr6 = CARES_INADDR_CAST(struct sockaddr_in6 *, sa);
port = addr6->sin6_port;
} else {
@ -142,7 +143,7 @@ static void ares_getnameinfo_int(ares_channel_t *channel,
callback(arg, ARES_EBADFLAGS, 0, NULL, NULL);
return;
}
if (salen == sizeof(struct sockaddr_in6)) {
if (sa->sa_family == AF_INET6) {
ares_inet_ntop(AF_INET6, &addr6->sin6_addr, ipbuf, IPBUFSIZ);
/* If the system supports scope IDs, use it */
#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
@ -158,9 +159,8 @@ static void ares_getnameinfo_int(ares_channel_t *channel,
}
callback(arg, ARES_SUCCESS, 0, ipbuf, service);
return;
}
/* This is where a DNS lookup becomes necessary */
else {
} else {
/* This is where a DNS lookup becomes necessary */
niquery = ares_malloc(sizeof(struct nameinfo_query));
if (!niquery) {
callback(arg, ARES_ENOMEM, 0, NULL, NULL);

View file

@ -29,7 +29,7 @@
#include "ares.h"
#include "ares_private.h"
int ares_getsock(ares_channel_t *channel, ares_socket_t *socks,
int ares_getsock(const ares_channel_t *channel, ares_socket_t *socks,
int numsocks) /* size of the 'socks' array */
{
ares__slist_node_t *snode;

View file

@ -65,6 +65,7 @@
#include "ares_inet_net_pton.h"
#include "ares_platform.h"
#include "ares_private.h"
#include "ares_event.h"
#ifdef WATT32
# undef WIN32 /* Redefined in MingW/MSVC headers */
@ -256,6 +257,12 @@ static ares_status_t init_by_defaults(ares_channel_t *channel)
}
}
/* Set default fields for server failover behavior */
if (!(channel->optmask & ARES_OPT_SERVER_FAILOVER)) {
channel->server_retry_chance = DEFAULT_SERVER_RETRY_CHANCE;
channel->server_retry_delay = DEFAULT_SERVER_RETRY_DELAY;
}
error:
if (hostname) {
ares_free(hostname);
@ -373,10 +380,21 @@ int ares_init_options(ares_channel_t **channelptr,
/* Initialize the event thread */
if (channel->optmask & ARES_OPT_EVENT_THREAD) {
ares_event_thread_t *e = NULL;
status = ares_event_thread_init(channel);
if (status != ARES_SUCCESS) {
goto done;
}
/* Initialize monitor for configuration changes. In some rare cases,
* ARES_ENOTIMP may occur (OpenWatcom), ignore this. */
e = channel->sock_state_cb_data;
status = ares_event_configchg_init(&e->configchg, e);
if (status != ARES_SUCCESS && status != ARES_ENOTIMP) {
goto done;
}
status = ARES_SUCCESS;
}
done:
@ -389,9 +407,35 @@ done:
return ARES_SUCCESS;
}
static void *ares_reinit_thread(void *arg)
{
ares_channel_t *channel = arg;
ares_status_t status;
/* ares__init_by_sysconfig() will lock when applying the config, but not
* when retrieving. */
status = ares__init_by_sysconfig(channel);
if (status != ARES_SUCCESS) {
DEBUGF(fprintf(stderr, "Error: init_by_sysconfig failed: %s\n",
ares_strerror(status)));
}
ares__channel_lock(channel);
/* Flush cached queries on reinit */
if (status == ARES_SUCCESS && channel->qcache) {
ares__qcache_flush(channel->qcache);
}
channel->reinit_pending = ARES_FALSE;
ares__channel_unlock(channel);
return NULL;
}
ares_status_t ares_reinit(ares_channel_t *channel)
{
ares_status_t status;
ares_status_t status = ARES_SUCCESS;
if (channel == NULL) {
return ARES_EFORMERR;
@ -399,25 +443,42 @@ ares_status_t ares_reinit(ares_channel_t *channel)
ares__channel_lock(channel);
status = ares__init_by_sysconfig(channel);
if (status != ARES_SUCCESS) {
DEBUGF(fprintf(stderr, "Error: init_by_sysconfig failed: %s\n",
ares_strerror(status)));
/* If a reinit is already in process, lets not do it again */
if (channel->reinit_pending) {
ares__channel_unlock(channel);
return ARES_SUCCESS;
}
/* Flush cached queries on reinit */
if (channel->qcache) {
ares__qcache_flush(channel->qcache);
}
channel->reinit_pending = ARES_TRUE;
ares__channel_unlock(channel);
if (ares_threadsafety()) {
/* clean up the prior reinit process's thread. We know the thread isn't
* running since reinit_pending was false */
if (channel->reinit_thread != NULL) {
void *rv;
ares__thread_join(channel->reinit_thread, &rv);
channel->reinit_thread = NULL;
}
/* Spawn a new thread */
status =
ares__thread_create(&channel->reinit_thread, ares_reinit_thread, channel);
if (status != ARES_SUCCESS) {
ares__channel_lock(channel);
channel->reinit_pending = ARES_FALSE;
ares__channel_unlock(channel);
}
} else {
/* Threading support not available, call directly */
ares_reinit_thread(channel);
}
return status;
}
/* ares_dup() duplicates a channel handle with all its options and returns a
new channel handle */
int ares_dup(ares_channel_t **dest, ares_channel_t *src)
int ares_dup(ares_channel_t **dest, const ares_channel_t *src)
{
struct ares_options opts;
ares_status_t rc;
@ -450,12 +511,14 @@ int ares_dup(ares_channel_t **dest, ares_channel_t *src)
/* Now clone the options that ares_save_options() doesn't support, but are
* user-provided */
(*dest)->sock_create_cb = src->sock_create_cb;
(*dest)->sock_create_cb_data = src->sock_create_cb_data;
(*dest)->sock_config_cb = src->sock_config_cb;
(*dest)->sock_config_cb_data = src->sock_config_cb_data;
(*dest)->sock_funcs = src->sock_funcs;
(*dest)->sock_func_cb_data = src->sock_func_cb_data;
(*dest)->sock_create_cb = src->sock_create_cb;
(*dest)->sock_create_cb_data = src->sock_create_cb_data;
(*dest)->sock_config_cb = src->sock_config_cb;
(*dest)->sock_config_cb_data = src->sock_config_cb_data;
(*dest)->sock_funcs = src->sock_funcs;
(*dest)->sock_func_cb_data = src->sock_func_cb_data;
(*dest)->server_state_cb = src->server_state_cb;
(*dest)->server_state_cb_data = src->server_state_cb_data;
ares_strcpy((*dest)->local_dev_name, src->local_dev_name,
sizeof((*dest)->local_dev_name));

View file

@ -31,6 +31,15 @@
# include <netinet6/in6.h>
#endif
#if defined(USE_WINSOCK)
# if defined(HAVE_IPHLPAPI_H)
# include <iphlpapi.h>
# endif
# if defined(HAVE_NETIOAPI_H)
# include <netioapi.h>
# endif
#endif
#ifndef HAVE_PF_INET6
# define PF_INET6 AF_INET6
#endif

View file

@ -53,8 +53,8 @@ void ares_destroy_options(struct ares_options *options)
ares_free(options->hosts_path);
}
static struct in_addr *ares_save_opt_servers(ares_channel_t *channel,
int *nservers)
static struct in_addr *ares_save_opt_servers(const ares_channel_t *channel,
int *nservers)
{
ares__slist_node_t *snode;
struct in_addr *out =
@ -82,8 +82,8 @@ static struct in_addr *ares_save_opt_servers(ares_channel_t *channel,
}
/* Save options from initialized channel */
int ares_save_options(ares_channel_t *channel, struct ares_options *options,
int *optmask)
int ares_save_options(const ares_channel_t *channel,
struct ares_options *options, int *optmask)
{
size_t i;
@ -229,6 +229,12 @@ int ares_save_options(ares_channel_t *channel, struct ares_options *options,
options->evsys = channel->evsys;
}
/* Set options for server failover behavior */
if (channel->optmask & ARES_OPT_SERVER_FAILOVER) {
options->server_failover_opts.retry_chance = channel->server_retry_chance;
options->server_failover_opts.retry_delay = channel->server_retry_delay;
}
*optmask = (int)channel->optmask;
return ARES_SUCCESS;
@ -474,6 +480,12 @@ ares_status_t ares__init_by_options(ares_channel_t *channel,
}
}
/* Set fields for server failover behavior */
if (optmask & ARES_OPT_SERVER_FAILOVER) {
channel->server_retry_chance = options->server_failover_opts.retry_chance;
channel->server_retry_delay = options->server_failover_opts.retry_delay;
}
channel->optmask = (unsigned int)optmask;
return ARES_SUCCESS;

File diff suppressed because it is too large Load diff

View file

@ -114,6 +114,7 @@ typedef struct ares_rand_state ares_rand_state;
#include "ares__htable_strvp.h"
#include "ares__htable_szvp.h"
#include "ares__htable_asvp.h"
#include "ares__htable_vpvp.h"
#include "ares__buf.h"
#include "ares_dns_private.h"
#include "ares__iface_ips.h"
@ -146,6 +147,11 @@ typedef struct ares_rand_state ares_rand_state;
/********* EDNS defines section ******/
/* Default values for server failover behavior. We retry failed servers with
* a 10% probability and a minimum delay of 5 seconds between retries.
*/
#define DEFAULT_SERVER_RETRY_CHANCE 10
#define DEFAULT_SERVER_RETRY_DELAY 5000
struct query;
@ -176,6 +182,9 @@ struct server_state {
ares__llist_t *connections;
struct server_connection *tcp_conn;
/* The next time when we will retry this server if it has hit failures */
struct timeval next_retry_time;
/* TCP buffer since multiple responses can come back in one read, or partial
* in a read */
ares__buf_t *tcp_parser;
@ -315,6 +324,27 @@ struct ares_channeldata {
/* Query Cache */
ares__qcache_t *qcache;
/* Fields controlling server failover behavior.
* The retry chance is the probability (1/N) by which we will retry a failed
* server instead of the best server when selecting a server to send queries
* to.
* The retry delay is the minimum time in milliseconds to wait between doing
* such retries (applied per-server).
*/
unsigned short server_retry_chance;
size_t server_retry_delay;
/* Callback triggered when a server has a successful or failed response */
ares_server_state_callback server_state_cb;
void *server_state_cb_data;
/* TRUE if a reinit is pending. Reinit spawns a thread to read the system
* configuration and then apply the configuration since configuration
* reading may block. The thread handle is provided for waiting on thread
* exit. */
ares_bool_t reinit_pending;
ares__thread_t *reinit_thread;
};
/* Does the domain end in ".onion" or ".onion."? Case-insensitive. */
@ -408,10 +438,17 @@ typedef struct {
ares_bool_t usevc;
} ares_sysconfig_t;
ares_status_t ares__sysconfig_set_options(ares_sysconfig_t *sysconfig,
const char *str);
ares_status_t ares__init_by_environment(ares_sysconfig_t *sysconfig);
ares_status_t ares__init_sysconfig_files(const ares_channel_t *channel,
ares_sysconfig_t *sysconfig);
#ifdef __APPLE__
ares_status_t ares__init_sysconfig_macos(ares_sysconfig_t *sysconfig);
#endif
ares_status_t ares__parse_sortlist(struct apattern **sortlist, size_t *nsort,
const char *str);
@ -497,6 +534,8 @@ ares_status_t ares__sconfig_append_fromstr(ares__llist_t **sconfig,
ares_status_t ares_in_addr_to_server_config_llist(const struct in_addr *servers,
size_t nservers,
ares__llist_t **llist);
ares_status_t ares_get_server_addr(const struct server_state *server,
ares__buf_t *buf);
struct ares_hosts_entry;
typedef struct ares_hosts_entry ares_hosts_entry_t;
@ -580,9 +619,9 @@ void ares_queue_notify_empty(ares_channel_t *channel);
} \
} while (0)
#define ARES_CONFIG_CHECK(x) \
(x && x->lookups && ares__slist_len(x->servers) > 0 && \
x->timeout > 0 && x->tries > 0)
#define ARES_CONFIG_CHECK(x) \
(x && x->lookups && ares__slist_len(x->servers) > 0 && x->timeout > 0 && \
x->tries > 0)
ares_bool_t ares__subnet_match(const struct ares_addr *addr,
const struct ares_addr *subnet,
@ -611,8 +650,8 @@ ares_status_t ares_qcache_fetch(ares_channel_t *channel,
ares_status_t ares__channel_threading_init(ares_channel_t *channel);
void ares__channel_threading_destroy(ares_channel_t *channel);
void ares__channel_lock(ares_channel_t *channel);
void ares__channel_unlock(ares_channel_t *channel);
void ares__channel_lock(const ares_channel_t *channel);
void ares__channel_unlock(const ares_channel_t *channel);
struct ares_event_thread;
typedef struct ares_event_thread ares_event_thread_t;

View file

@ -50,6 +50,7 @@
#include "ares_nameser.h"
#include "ares_dns.h"
static void timeadd(struct timeval *now, size_t millisecs);
static ares_bool_t try_again(int errnum);
static void write_tcp_data(ares_channel_t *channel, fd_set *write_fds,
ares_socket_t write_fd);
@ -70,35 +71,86 @@ static ares_bool_t same_address(const struct sockaddr *sa,
static void end_query(ares_channel_t *channel, struct query *query,
ares_status_t status, const ares_dns_record_t *dnsrec);
static void server_increment_failures(struct server_state *server)
/* Invoke the server state callback after a success or failure */
static void invoke_server_state_cb(const struct server_state *server,
ares_bool_t success, int flags)
{
ares__slist_node_t *node;
const ares_channel_t *channel = server->channel;
ares__buf_t *buf;
ares_status_t status;
char *server_string;
node = ares__slist_node_find(channel->servers, server);
if (node == NULL) {
if (channel->server_state_cb == NULL) {
return;
}
server->consec_failures++;
ares__slist_node_reinsert(node);
buf = ares__buf_create();
if (buf == NULL) {
return;
}
status = ares_get_server_addr(server, buf);
if (status != ARES_SUCCESS) {
ares__buf_destroy(buf);
return;
}
server_string = ares__buf_finish_str(buf, NULL);
buf = NULL;
if (server_string == NULL) {
return;
}
channel->server_state_cb(server_string, success, flags,
channel->server_state_cb_data);
ares_free(server_string);
}
static void server_set_good(struct server_state *server)
static void server_increment_failures(struct server_state *server,
ares_bool_t used_tcp)
{
ares__slist_node_t *node;
const ares_channel_t *channel = server->channel;
if (!server->consec_failures) {
return;
}
struct timeval next_retry_time;
node = ares__slist_node_find(channel->servers, server);
if (node == NULL) {
return;
}
server->consec_failures = 0;
server->consec_failures++;
ares__slist_node_reinsert(node);
next_retry_time = ares__tvnow();
timeadd(&next_retry_time, channel->server_retry_delay);
server->next_retry_time = next_retry_time;
invoke_server_state_cb(server, ARES_FALSE,
used_tcp == ARES_TRUE ? ARES_SERV_STATE_TCP
: ARES_SERV_STATE_UDP);
}
static void server_set_good(struct server_state *server, ares_bool_t used_tcp)
{
ares__slist_node_t *node;
const ares_channel_t *channel = server->channel;
node = ares__slist_node_find(channel->servers, server);
if (node == NULL) {
return;
}
if (server->consec_failures > 0) {
server->consec_failures = 0;
ares__slist_node_reinsert(node);
}
server->next_retry_time.tv_sec = 0;
server->next_retry_time.tv_usec = 0;
invoke_server_state_cb(server, ARES_TRUE,
used_tcp == ARES_TRUE ? ARES_SERV_STATE_TCP
: ARES_SERV_STATE_UDP);
}
/* return true if now is exactly check time or later */
@ -561,7 +613,7 @@ static void process_timeouts(ares_channel_t *channel, struct timeval *now)
query->timeouts++;
conn = query->conn;
server_increment_failures(conn->server);
server_increment_failures(conn->server, query->using_tcp);
ares__requeue_query(query, now);
ares__check_cleanup_conn(channel, conn);
@ -716,7 +768,7 @@ static ares_status_t process_answer(ares_channel_t *channel,
break;
}
server_increment_failures(server);
server_increment_failures(server, query->using_tcp);
ares__requeue_query(query, now);
/* Should any of these cause a connection termination?
@ -732,7 +784,7 @@ static ares_status_t process_answer(ares_channel_t *channel,
is_cached = ARES_TRUE;
}
server_set_good(server);
server_set_good(server, query->using_tcp);
end_query(channel, query, ARES_SUCCESS, rdnsrec);
status = ARES_SUCCESS;
@ -755,7 +807,7 @@ static void handle_conn_error(struct server_connection *conn,
/* Increment failures first before requeue so it is unlikely to requeue
* to the same server */
if (critical_failure) {
server_increment_failures(server);
server_increment_failures(server, conn->is_tcp);
}
/* This will requeue any connections automatically */
@ -816,6 +868,66 @@ static struct server_state *ares__random_server(ares_channel_t *channel)
return NULL;
}
/* Pick a server from the list with failover behavior.
*
* We default to using the first server in the sorted list of servers. That is
* the server with the lowest number of consecutive failures and then the
* highest priority server (by idx) if there is a draw.
*
* However, if a server temporarily goes down and hits some failures, then that
* server will never be retried until all other servers hit the same number of
* failures. This may prevent the server from being retried for a long time.
*
* To resolve this, with some probability we select a failed server to retry
* instead.
*/
static struct server_state *ares__failover_server(ares_channel_t *channel)
{
struct server_state *first_server = ares__slist_first_val(channel->servers);
struct server_state *last_server = ares__slist_last_val(channel->servers);
unsigned short r;
/* Defensive code against no servers being available on the channel. */
if (first_server == NULL) {
return NULL;
}
/* If no servers have failures, then prefer the first server in the list. */
if (last_server != NULL && last_server->consec_failures == 0) {
return first_server;
}
/* If we are not configured with a server retry chance then return the first
* server.
*/
if (channel->server_retry_chance == 0) {
return first_server;
}
/* Generate a random value to decide whether to retry a failed server. The
* probability to use is 1/channel->server_retry_chance, rounded up to a
* precision of 1/2^B where B is the number of bits in the random value.
* We use an unsigned short for the random value for increased precision.
*/
ares__rand_bytes(channel->rand_state, (unsigned char *)&r, sizeof(r));
if (r % channel->server_retry_chance == 0) {
/* Select a suitable failed server to retry. */
struct timeval now = ares__tvnow();
ares__slist_node_t *node;
for (node = ares__slist_node_first(channel->servers); node != NULL;
node = ares__slist_node_next(node)) {
struct server_state *node_val = ares__slist_node_val(node);
if (node_val != NULL && node_val->consec_failures > 0 &&
ares__timedout(&now, &node_val->next_retry_time)) {
return node_val;
}
}
}
/* If we have not returned yet, then return the first server. */
return first_server;
}
static ares_status_t ares__append_tcpbuf(struct server_state *server,
const struct query *query)
{
@ -890,10 +1002,11 @@ ares_status_t ares__send_query(struct query *query, struct timeval *now)
/* Choose the server to send the query to */
if (channel->rotate) {
/* Pull random server */
server = ares__random_server(channel);
} else {
/* Pull first */
server = ares__slist_first_val(channel->servers);
/* Pull server with failover behavior */
server = ares__failover_server(channel);
}
if (server == NULL) {
@ -918,7 +1031,7 @@ ares_status_t ares__send_query(struct query *query, struct timeval *now)
* error codes */
case ARES_ECONNREFUSED:
case ARES_EBADFAMILY:
server_increment_failures(server);
server_increment_failures(server, query->using_tcp);
query->error_status = status;
return ares__requeue_query(query, now);
@ -977,7 +1090,7 @@ ares_status_t ares__send_query(struct query *query, struct timeval *now)
* error codes */
case ARES_ECONNREFUSED:
case ARES_EBADFAMILY:
server_increment_failures(server);
server_increment_failures(server, query->using_tcp);
query->error_status = status;
return ares__requeue_query(query, now);
@ -992,7 +1105,7 @@ ares_status_t ares__send_query(struct query *query, struct timeval *now)
conn = ares__llist_node_val(node);
if (ares__socket_write(channel, conn->fd, query->qbuf, query->qlen) == -1) {
/* FIXME: Handle EAGAIN here since it likely can happen. */
server_increment_failures(server);
server_increment_failures(server, query->using_tcp);
status = ares__requeue_query(query, now);
/* Only safe to kill connection if it was new, otherwise it should be

View file

@ -200,7 +200,7 @@ void ares_send(ares_channel_t *channel, const unsigned char *qbuf, int qlen,
ares_dns_record_destroy(dnsrec);
}
size_t ares_queue_active_queries(ares_channel_t *channel)
size_t ares_queue_active_queries(const ares_channel_t *channel)
{
size_t len;

View file

@ -957,23 +957,24 @@ static ares_status_t ares__init_sysconfig_libresolv(ares_sysconfig_t *sysconfig)
if (res.ndots >= 0) {
sysconfig->ndots = (size_t)res.ndots;
}
/* Apple does not allow configuration of retry, so this is a static dummy
* value, ignore */
# ifndef __APPLE__
if (res.retry > 0) {
sysconfig->tries = (size_t)res.retry;
}
# endif
if (res.options & RES_ROTATE) {
sysconfig->rotate = ARES_TRUE;
}
if (res.retrans > 0) {
/* Apple does not allow configuration of retrans, so this is a dummy value
* that is extremely high (5s) */
# ifndef __APPLE__
if (res.retrans > 0) {
sysconfig->timeout_ms = (unsigned int)res.retrans * 1000;
}
# ifdef __APPLE__
if (res.retry >= 0) {
sysconfig->timeout_ms /=
((unsigned int)res.retry + 1) *
(unsigned int)(res.nscount > 0 ? res.nscount : 1);
}
# endif
}
@ -1083,6 +1084,8 @@ ares_status_t ares__init_by_sysconfig(ares_channel_t *channel)
status = ares__init_sysconfig_watt32(&sysconfig);
#elif defined(ANDROID) || defined(__ANDROID__)
status = ares__init_sysconfig_android(&sysconfig);
#elif defined(__APPLE__)
status = ares__init_sysconfig_macos(&sysconfig);
#elif defined(CARES_USE_LIBRESOLV)
status = ares__init_sysconfig_libresolv(&sysconfig);
#else
@ -1099,7 +1102,14 @@ ares_status_t ares__init_by_sysconfig(ares_channel_t *channel)
goto done;
}
/* Lock when applying the configuration to the channel. Don't need to
* lock prior to this. */
ares__channel_lock(channel);
status = ares_sysconfig_apply(channel, &sysconfig);
ares__channel_unlock(channel);
if (status != ARES_SUCCESS) {
goto done;
}

Some files were not shown because too many files have changed in this diff Show more