]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
c-ares: fix/tidy-up macro initializations, avoid a deprecated function
authorViktor Szakats <commit@vsz.me>
Thu, 30 Jan 2025 11:42:52 +0000 (12:42 +0100)
committerViktor Szakats <commit@vsz.me>
Mon, 3 Feb 2025 18:04:50 +0000 (19:04 +0100)
- replace deprecated `ares_init()` call with `ares_init_options()`.
  Follow-up to 0d4fdbf15d8eec908b3e63b606f112b18a63015e #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

CMakeLists.txt
lib/asyn-ares.c
lib/asyn-thread.c
lib/curl_setup.h
lib/version.c
m4/curl-confopts.m4

index 0a81ef41e14db4f291a2ba14befe721f453e1879..30c0154be78b3308db9f15504dded393f02c6d29 100644 (file)
@@ -352,7 +352,6 @@ if(ENABLE_ARES)
   if(CARES_CFLAGS)
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CARES_CFLAGS}")
   endif()
-  add_definitions("-DCARES_NO_DEPRECATED")  # Ignore c-ares deprecation warnings
 endif()
 
 include(CurlSymbolHiding)
index 44e009b11d304c537545f990209bf5b73bb9cc43..38dc729e04d8909bc898a8f3d84f42f461aef132 100644 (file)
 #include "httpsrr.h"
 #include "strdup.h"
 
-#if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) &&   \
-  defined(_WIN32)
-#  define CARES_STATICLIB
-#endif
 #include <ares.h>
 #include <ares_version.h> /* really old c-ares did not include this by
                              itself */
index 895efbc7b577718fc51064c4bebe37701bcfdf14..b8c304943d18930a6f89f71a8ae446e5d719216e 100644 (file)
@@ -429,7 +429,7 @@ static void destroy_async_data(struct Curl_async *async)
 static CURLcode resolve_httpsrr(struct Curl_easy *data,
                                 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)
     return CURLE_FAILED_INIT;
 
index 71326c35e6ee5ae23fe9fcc9a4d52df49b071ec4..cc1b7e55dae046cb3aabb06a1aec96ab680b7792 100644 (file)
 #  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
 #  include <lwip/init.h>
 #  include <lwip/sockets.h>
index 166fabd79c31a8ee9213a0b269bc6fc71c92ba8a..6543dcd0bd5f102f7710086b4bca44a932fa5766 100644 (file)
 #include "easy_lock.h"
 
 #ifdef USE_ARES
-#  if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) &&   \
-  defined(_WIN32)
-#    define CARES_STATICLIB
-#  endif
 #  include <ares.h>
 #endif
 
index 7da8cb58be1c5ab05aa2a4a5d1a300b0e92f1320..dd23fc7c0729c6c0735789085221235c0a845bf3 100644 (file)
@@ -532,7 +532,6 @@ AC_DEFUN([CURL_CHECK_LIB_ARES], [
     if test "$want_ares" = "yes"; then
       dnl finally c-ares will be used
       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
       LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE libcares"
       curl_res_msg="c-ares"