c-ares: fix/tidy-up macro initializations, avoid a deprecated function
- replace deprecated `ares_init()` call with `ares_init_options()`.
Follow-up to 0d4fdbf15d #16054
- dedupe `CARES_STATICLIB` initalizations into `curl_setup.h`, to
ensure it's defined before the first (and every) `ares.h` include and
avoid a potential confusion.
- move `CARES_NO_DEPRECATED` from build level to `curl_setup.h`.
To work regardless of build system.
It is necessary because curl calls `ares_getsock()` from two places,
of which one feeds a chain of wrappers: `Curl_ares_getsock()`,
`Curl_resolver_getsock()`, `Curl_resolv_getsock()`.
Closes #16131
This commit is contained in:
parent
4f95f32709
commit
671e83f0b1
@ -352,7 +352,6 @@ if(ENABLE_ARES)
|
|||||||
if(CARES_CFLAGS)
|
if(CARES_CFLAGS)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CARES_CFLAGS}")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CARES_CFLAGS}")
|
||||||
endif()
|
endif()
|
||||||
add_definitions("-DCARES_NO_DEPRECATED") # Ignore c-ares deprecation warnings
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(CurlSymbolHiding)
|
include(CurlSymbolHiding)
|
||||||
|
|||||||
@ -62,10 +62,6 @@
|
|||||||
#include "httpsrr.h"
|
#include "httpsrr.h"
|
||||||
#include "strdup.h"
|
#include "strdup.h"
|
||||||
|
|
||||||
#if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
|
|
||||||
defined(_WIN32)
|
|
||||||
# define CARES_STATICLIB
|
|
||||||
#endif
|
|
||||||
#include <ares.h>
|
#include <ares.h>
|
||||||
#include <ares_version.h> /* really old c-ares did not include this by
|
#include <ares_version.h> /* really old c-ares did not include this by
|
||||||
itself */
|
itself */
|
||||||
|
|||||||
@ -429,7 +429,7 @@ static void destroy_async_data(struct Curl_async *async)
|
|||||||
static CURLcode resolve_httpsrr(struct Curl_easy *data,
|
static CURLcode resolve_httpsrr(struct Curl_easy *data,
|
||||||
struct Curl_async *asp)
|
struct Curl_async *asp)
|
||||||
{
|
{
|
||||||
int status = ares_init(&asp->tdata->channel);
|
int status = ares_init_options(&asp->tdata->channel, NULL, 0);
|
||||||
if(status != ARES_SUCCESS)
|
if(status != ARES_SUCCESS)
|
||||||
return CURLE_FAILED_INIT;
|
return CURLE_FAILED_INIT;
|
||||||
|
|
||||||
|
|||||||
@ -377,6 +377,15 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_ARES
|
||||||
|
# ifndef CARES_NO_DEPRECATED
|
||||||
|
# define CARES_NO_DEPRECATED /* for ares_getsock() */
|
||||||
|
# endif
|
||||||
|
# if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && defined(_WIN32)
|
||||||
|
# define CARES_STATICLIB /* define it before including ares.h */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_LWIPSOCK
|
#ifdef USE_LWIPSOCK
|
||||||
# include <lwip/init.h>
|
# include <lwip/init.h>
|
||||||
# include <lwip/sockets.h>
|
# include <lwip/sockets.h>
|
||||||
|
|||||||
@ -38,10 +38,6 @@
|
|||||||
#include "easy_lock.h"
|
#include "easy_lock.h"
|
||||||
|
|
||||||
#ifdef USE_ARES
|
#ifdef USE_ARES
|
||||||
# if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
|
|
||||||
defined(_WIN32)
|
|
||||||
# define CARES_STATICLIB
|
|
||||||
# endif
|
|
||||||
# include <ares.h>
|
# include <ares.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -532,7 +532,6 @@ AC_DEFUN([CURL_CHECK_LIB_ARES], [
|
|||||||
if test "$want_ares" = "yes"; then
|
if test "$want_ares" = "yes"; then
|
||||||
dnl finally c-ares will be used
|
dnl finally c-ares will be used
|
||||||
AC_DEFINE(USE_ARES, 1, [Define to enable c-ares support])
|
AC_DEFINE(USE_ARES, 1, [Define to enable c-ares support])
|
||||||
AC_DEFINE(CARES_NO_DEPRECATED, 1, [Ignore c-ares deprecation warnings])
|
|
||||||
USE_ARES=1
|
USE_ARES=1
|
||||||
LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE libcares"
|
LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE libcares"
|
||||||
curl_res_msg="c-ares"
|
curl_res_msg="c-ares"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user