Skip to content

Commit

Permalink
deps: update c-ares to v1.32.2
Browse files Browse the repository at this point in the history
PR-URL: #53865
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
nodejs-github-bot authored Jul 24, 2024
1 parent 2208948 commit c79a674
Show file tree
Hide file tree
Showing 17 changed files with 757 additions and 281 deletions.
4 changes: 2 additions & 2 deletions deps/cares/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ INCLUDE (CheckCSourceCompiles)
INCLUDE (CheckStructHasMember)
INCLUDE (CheckLibraryExists)

PROJECT (c-ares LANGUAGES C VERSION "1.32.1" )
PROJECT (c-ares LANGUAGES C VERSION "1.32.2" )

# Set this version before release
SET (CARES_VERSION "${PROJECT_VERSION}")
Expand All @@ -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 "19:1:17")
SET (CARES_LIB_VERSIONINFO "19:2:17")


OPTION (CARES_STATIC "Build as a static library" OFF)
Expand Down
24 changes: 24 additions & 0 deletions deps/cares/RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
## c-ares version 1.32.2 - July 15 2024

This is a bugfix release.

Bugfixes:

* Windows: rework EventThread AFD code for better stability.
[PR #811](https://github.com/c-ares/c-ares/pull/811)
* Windows: If an IP address was detected to have changed, it could lead to a
crash due to a bad pointer. Regression introduced in 1.31.0.
[59e3a1f4](https://github.com/c-ares/c-ares/commit/59e3a1f4)
* Windows: use `QueryPerformanceCounters()` instead of `GetTickCount64()` for
better time accuracy (~15ms -> ~1us).
* Windows 32bit config change callback needs to be tagged as `stdcall` otherwise
could result in a crash.
[5c2bab35](https://github.com/c-ares/c-ares/commit/5c2bab35)
* Tests that need accurate timing should not depend on internal symbols as there
are C++ equivalents in `std::chrono`.
[PR #809](https://github.com/c-ares/c-ares/pull/809)
* Kqueue (MacOS, \*BSD): If the open socket count exceeded 8 (unlikely), it
would try to allocate a new buffer that was too small.
[5aad7981](https://github.com/c-ares/c-ares/commit/5aad7981)


## c-ares version 1.32.1 - July 7 2024

This is a bugfix release.
Expand Down
2 changes: 1 addition & 1 deletion deps/cares/aminclude_static.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

# aminclude_static.am generated automatically by Autoconf
# from AX_AM_MACROS_STATIC on Sun Jul 7 10:45:53 EDT 2024
# from AX_AM_MACROS_STATIC on Mon Jul 15 09:00:09 EDT 2024


# Code coverage
Expand Down
22 changes: 11 additions & 11 deletions deps/cares/configure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.72 for c-ares 1.32.1.
# Generated by GNU Autoconf 2.72 for c-ares 1.32.2.
#
# Report bugs to <c-ares mailing list: http://lists.haxx.se/listinfo/c-ares>.
#
Expand Down Expand Up @@ -614,8 +614,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='c-ares'
PACKAGE_TARNAME='c-ares'
PACKAGE_VERSION='1.32.1'
PACKAGE_STRING='c-ares 1.32.1'
PACKAGE_VERSION='1.32.2'
PACKAGE_STRING='c-ares 1.32.2'
PACKAGE_BUGREPORT='c-ares mailing list: http://lists.haxx.se/listinfo/c-ares'
PACKAGE_URL=''

Expand Down Expand Up @@ -1415,7 +1415,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.32.1 to adapt to many kinds of systems.
'configure' configures c-ares 1.32.2 to adapt to many kinds of systems.

Usage: $0 [OPTION]... [VAR=VALUE]...

Expand Down Expand Up @@ -1486,7 +1486,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of c-ares 1.32.1:";;
short | recursive ) echo "Configuration of c-ares 1.32.2:";;
esac
cat <<\_ACEOF

Expand Down Expand Up @@ -1623,7 +1623,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
c-ares configure 1.32.1
c-ares configure 1.32.2
generated by GNU Autoconf 2.72

Copyright (C) 2023 Free Software Foundation, Inc.
Expand Down Expand Up @@ -2267,7 +2267,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.32.1, which was
It was created by c-ares $as_me 1.32.2, which was
generated by GNU Autoconf 2.72. Invocation command line was

$ $0$ac_configure_args_raw
Expand Down Expand Up @@ -3259,7 +3259,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu



CARES_VERSION_INFO="19:1:17"
CARES_VERSION_INFO="19:2:17"



Expand Down Expand Up @@ -5999,7 +5999,7 @@ fi

# Define the identity of the package.
PACKAGE='c-ares'
VERSION='1.32.1'
VERSION='1.32.2'


printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
Expand Down Expand Up @@ -26339,7 +26339,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.32.1, which was
This file was extended by c-ares $as_me 1.32.2, which was
generated by GNU Autoconf 2.72. Invocation command line was

CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -26407,7 +26407,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.32.1
c-ares config.status 1.32.2
configured by $0, generated by GNU Autoconf 2.72,
with options \\"\$ac_cs_config\\"

Expand Down
4 changes: 2 additions & 2 deletions deps/cares/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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.32.1],
AC_INIT([c-ares], [1.32.2],
[c-ares mailing list: http://lists.haxx.se/listinfo/c-ares])

CARES_VERSION_INFO="19:1:17"
CARES_VERSION_INFO="19:2:17"
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.
Expand Down
4 changes: 2 additions & 2 deletions deps/cares/include/ares_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@

#define ARES_VERSION_MAJOR 1
#define ARES_VERSION_MINOR 32
#define ARES_VERSION_PATCH 1
#define ARES_VERSION_PATCH 2
#define ARES_VERSION \
((ARES_VERSION_MAJOR << 16) | (ARES_VERSION_MINOR << 8) | \
(ARES_VERSION_PATCH))
#define ARES_VERSION_STR "1.32.1"
#define ARES_VERSION_STR "1.32.2"

#define CARES_HAVE_ARES_LIBRARY_INIT 1
#define CARES_HAVE_ARES_LIBRARY_CLEANUP 1
Expand Down
2 changes: 1 addition & 1 deletion deps/cares/src/lib/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@SET_MAKE@

# aminclude_static.am generated automatically by Autoconf
# from AX_AM_MACROS_STATIC on Sun Jul 7 10:45:53 EDT 2024
# from AX_AM_MACROS_STATIC on Mon Jul 15 09:00:09 EDT 2024

# Copyright (C) The c-ares project and its contributors
# SPDX-License-Identifier: MIT
Expand Down
21 changes: 17 additions & 4 deletions deps/cares/src/lib/ares__timeval.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,24 @@

void ares__tvnow(ares_timeval_t *now)
{
/* GetTickCount64() is available on Windows Vista and higher */
ULONGLONG milliseconds = GetTickCount64();
/* QueryPerformanceCounters() has been around since Windows 2000, though
* significant fixes were made in later versions. Documentation states
* 1 microsecond or better resolution with a rollover not less than 100 years.
* This differs from GetTickCount{64}() which has a resolution between 10 and
* 16 ms. */
LARGE_INTEGER freq;
LARGE_INTEGER current;

now->sec = (ares_int64_t)milliseconds / 1000;
now->usec = (unsigned int)(milliseconds % 1000) * 1000;
/* Not sure how long it takes to get the frequency, I see it recommended to
* cache it */
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&current);

now->sec = current.QuadPart / freq.QuadPart;
/* We want to prevent overflows so we get the remainder, then multiply to
* microseconds before dividing */
now->usec = (unsigned int)(((current.QuadPart % freq.QuadPart) * 1000000) /
freq.QuadPart);
}

#elif defined(HAVE_CLOCK_GETTIME_MONOTONIC)
Expand Down
18 changes: 15 additions & 3 deletions deps/cares/src/lib/ares_destroy.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,17 @@ void ares_destroy(ares_channel_t *channel)
return;
}

/* Disable configuration change monitoring */
/* Mark as being shutdown */
ares__channel_lock(channel);
channel->sys_up = ARES_FALSE;
ares__channel_unlock(channel);

/* Disable configuration change monitoring. We can't hold a lock because
* some cleanup routines, such as on Windows, are synchronous operations.
* What we've observed is a system config change event was triggered right
* at shutdown time and it tries to take the channel lock and the destruction
* waits for that event to complete before it continues so we get a channel
* lock deadlock at shutdown if we hold a lock during this process. */
if (channel->optmask & ARES_OPT_EVENT_THREAD) {
ares_event_thread_t *e = channel->sock_state_cb_data;
if (e && e->configchg) {
Expand All @@ -47,14 +57,16 @@ void ares_destroy(ares_channel_t *channel)
}
}

/* Wait for reinit thread to exit if there was one pending */
/* Wait for reinit thread to exit if there was one pending, can't be
* holding a lock as the thread may take locks. */
if (channel->reinit_thread != NULL) {
void *rv;
ares__thread_join(channel->reinit_thread, &rv);
channel->reinit_thread = NULL;
}

/* Lock because callbacks will be triggered */
/* Lock because callbacks will be triggered, and any system-generated
* callbacks need to hold a channel lock. */
ares__channel_lock(channel);

/* Destroy all queries */
Expand Down
11 changes: 6 additions & 5 deletions deps/cares/src/lib/ares_event_configchg.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,10 @@ void ares_event_configchg_destroy(ares_event_configchg_t *configchg)


# ifndef __WATCOMC__
static void ares_event_configchg_ip_cb(PVOID CallerContext,
PMIB_IPINTERFACE_ROW Row,
MIB_NOTIFICATION_TYPE NotificationType)
static void NETIOAPI_API_
ares_event_configchg_ip_cb(PVOID CallerContext,
PMIB_IPINTERFACE_ROW Row,
MIB_NOTIFICATION_TYPE NotificationType)
{
ares_event_configchg_t *configchg = CallerContext;
(void)Row;
Expand Down Expand Up @@ -303,8 +304,8 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg,
* that didn't get triggered either.
*/
if (NotifyIpInterfaceChange(
AF_UNSPEC, (PIPINTERFACE_CHANGE_CALLBACK)ares_event_configchg_ip_cb,
*configchg, FALSE, &c->ifchg_hnd) != NO_ERROR) {
AF_UNSPEC, ares_event_configchg_ip_cb,
c, FALSE, &c->ifchg_hnd) != NO_ERROR) {
status = ARES_ESERVFAIL;
goto done;
}
Expand Down
9 changes: 6 additions & 3 deletions deps/cares/src/lib/ares_event_kqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static ares_bool_t ares_evsys_kqueue_init(ares_event_thread_t *e)

kq->nchanges_alloc = 8;
kq->changelist =
ares_malloc_zero(sizeof(*kq->changelist) * kq->nchanges_alloc);
ares_malloc_zero(kq->nchanges_alloc * sizeof(*kq->changelist));
if (kq->changelist == NULL) {
ares_evsys_kqueue_destroy(e);
return ARES_FALSE;
Expand Down Expand Up @@ -123,8 +123,11 @@ static void ares_evsys_kqueue_enqueue(ares_evsys_kqueue_t *kq, int fd,

if (kq->nchanges > kq->nchanges_alloc) {
kq->nchanges_alloc <<= 1;
kq->changelist = ares_realloc_zero(kq->changelist, kq->nchanges_alloc >> 1,
kq->nchanges_alloc);
kq->changelist = ares_realloc_zero(
kq->changelist,
(kq->nchanges_alloc >> 1) * sizeof(*kq->changelist),
kq->nchanges_alloc * sizeof(*kq->changelist)
);
}

EV_SET(&kq->changelist[idx], fd, filter, flags, 0, 0, 0);
Expand Down
59 changes: 40 additions & 19 deletions deps/cares/src/lib/ares_event_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,35 @@ static void ares_event_process_updates(ares_event_thread_t *e)
}
}

static void ares_event_thread_cleanup(ares_event_thread_t *e)
{
/* Manually free any updates that weren't processed */
if (e->ev_updates != NULL) {
ares__llist_node_t *node;

while ((node = ares__llist_node_first(e->ev_updates)) != NULL) {
ares_event_destroy_cb(ares__llist_node_claim(node));
}
ares__llist_destroy(e->ev_updates);
e->ev_updates = NULL;
}

if (e->ev_sock_handles != NULL) {
ares__htable_asvp_destroy(e->ev_sock_handles);
e->ev_sock_handles = NULL;
}

if (e->ev_cust_handles != NULL) {
ares__htable_vpvp_destroy(e->ev_cust_handles);
e->ev_cust_handles = NULL;
}

if (e->ev_sys != NULL && e->ev_sys->destroy != NULL) {
e->ev_sys->destroy(e);
e->ev_sys = NULL;
}
}

static void *ares_event_thread(void *arg)
{
ares_event_thread_t *e = arg;
Expand Down Expand Up @@ -296,14 +325,16 @@ static void *ares_event_thread(void *arg)
ares__thread_mutex_lock(e->mutex);
}

/* Lets cleanup while we're in the thread itself */
ares_event_thread_cleanup(e);

ares__thread_mutex_unlock(e->mutex);

return NULL;
}

static void ares_event_thread_destroy_int(ares_event_thread_t *e)
{
ares__llist_node_t *node;

/* Wake thread and tell it to shutdown if it exists */
ares__thread_mutex_lock(e->mutex);
if (e->isup) {
Expand All @@ -314,26 +345,14 @@ static void ares_event_thread_destroy_int(ares_event_thread_t *e)

/* Wait for thread to shutdown */
if (e->thread) {
ares__thread_join(e->thread, NULL);
void *rv = NULL;
ares__thread_join(e->thread, &rv);
e->thread = NULL;
}

/* Manually free any updates that weren't processed */
while ((node = ares__llist_node_first(e->ev_updates)) != NULL) {
ares_event_destroy_cb(ares__llist_node_claim(node));
}
ares__llist_destroy(e->ev_updates);
e->ev_updates = NULL;

ares__htable_asvp_destroy(e->ev_sock_handles);
e->ev_sock_handles = NULL;

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);
}
/* If the event thread ever got to the point of starting, this is a no-op
* as it runs this same cleanup when it shuts down */
ares_event_thread_cleanup(e);

ares__thread_mutex_destroy(e->mutex);
e->mutex = NULL;
Expand All @@ -350,6 +369,8 @@ void ares_event_thread_destroy(ares_channel_t *channel)
}

ares_event_thread_destroy_int(e);
channel->sock_state_cb_data = NULL;
channel->sock_state_cb = NULL;
}

static const ares_event_sys_t *ares_event_fetch_sys(ares_evsys_t evsys)
Expand Down
Loading

0 comments on commit c79a674

Please sign in to comment.