]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
quic: use send/recvmmsg when available
authorStefan Eissing <sei@tux.icing.local>
Thu, 12 Sep 2024 10:24:42 +0000 (12:24 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 30 Sep 2024 06:51:16 +0000 (08:51 +0200)
add checks for sendmmsg in configure and CmakeLists.txt for enabling use
of these functions in ngtcp2/quiche quic.

Closes #14880

CMake/Platforms/WindowsCache.cmake
CMakeLists.txt
configure.ac
lib/curl_config.h.cmake
lib/curl_setup.h
lib/vquic/vquic.c
src/tool_operate.c

index 317f21c875cf7675ee054e2b577bafb2cc4727d2..57b2b40bd4387c4e0f7f6e94773bb6d551294991 100644 (file)
@@ -88,6 +88,7 @@ set(HAVE_FREEADDRINFO 1)
 set(HAVE_FCHMOD 0)
 set(HAVE_SOCKETPAIR 0)
 set(HAVE_SENDMSG 0)
+set(HAVE_SENDMMSG 0)
 set(HAVE_ALARM 0)
 set(HAVE_FCNTL 0)
 set(HAVE_GETPPID 0)
index 5c291e27b48372244987c0f6a234ce97ef9a8256..15964dd860f1c36cdf018719d277fcb9212966ea 100644 (file)
@@ -192,6 +192,10 @@ cmake_dependent_option(ENABLE_THREADED_RESOLVER "Enable threaded DNS lookup"
 
 include(PickyWarnings)
 
+if(CMAKE_SYSTEM_NAME MATCHES "Linux")
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE")  # Required for sendmmsg()
+endif()
+
 option(ENABLE_DEBUG "Enable curl debug features" OFF)
 option(ENABLE_CURLDEBUG "Enable TrackMemory feature" ${ENABLE_DEBUG})
 
@@ -1468,6 +1472,7 @@ check_symbol_exists("socketpair"      "${CURL_INCLUDES}" HAVE_SOCKETPAIR)
 check_symbol_exists("recv"            "${CURL_INCLUDES}" HAVE_RECV)
 check_symbol_exists("send"            "${CURL_INCLUDES}" HAVE_SEND)
 check_symbol_exists("sendmsg"         "${CURL_INCLUDES}" HAVE_SENDMSG)
+check_symbol_exists("sendmmsg"        "sys/socket.h" HAVE_SENDMMSG)
 check_symbol_exists("select"          "${CURL_INCLUDES}" HAVE_SELECT)
 check_symbol_exists("strdup"          "${CURL_INCLUDES};string.h" HAVE_STRDUP)
 check_symbol_exists("strtok_r"        "${CURL_INCLUDES};string.h" HAVE_STRTOK_R)
index e558032e51fa28348a7fcaab644b5bae177615f7..09db30cc401fae465c01c428aea69a5cd8db2275 100644 (file)
@@ -573,6 +573,14 @@ case $host_os in
     ;;
 esac
 
+# In order to detect support of sendmmsg(), we need to escape the POSIX
+# jail by defining _GNU_SOURCE or <sys/socket.h> will not expose it.
+case $host_os in
+  linux*)
+    CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+    ;;
+esac
+
 dnl Build unit tests when option --enable-debug is given.
 if test "x$want_debug" = "xyes" &&
    test "x$supports_unittests" = "xyes"; then
@@ -4102,6 +4110,7 @@ AC_CHECK_FUNCS([\
   pipe \
   sched_yield \
   sendmsg \
+  sendmmsg \
   setlocale \
   setmode \
   setrlimit \
index 9c785f334e003a555a62326d719be8f7d2339d8d..ef7a7a69338dc2cc5b6d509ddb60c968c2ff512d 100644 (file)
 /* Define to 1 if you have the sendmsg function. */
 #cmakedefine HAVE_SENDMSG 1
 
+/* Define to 1 if you have the sendmmsg function. */
+#cmakedefine HAVE_SENDMMSG 1
+
 /* Define to 1 if you have the 'fsetxattr' function. */
 #cmakedefine HAVE_FSETXATTR 1
 
index c9771d75445f3991750b3a062ff0228b506938c3..1c715fd4fee684ec7ae6df695a6b626f80c6ca33 100644 (file)
 /*  please, do it beyond the point further indicated in this file.  */
 /* ================================================================ */
 
+/* Give calloc a chance to be dragging in early, so we do not redefine */
+#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
+#  include <pthread.h>
+#endif
+
 /*
  * Disable other protocols when http is the only one desired.
  */
index 4648b5a072912556624bbcc8fbf6fa1224a21231..715328bc9e51587f8cd9eb3afe88c7b8ae6aa4d9 100644 (file)
  *
  ***************************************************************************/
 
-/* WIP, experimental: use recvmmsg() on Linux
- * we have no configure check, yet
- * and also it is only available for _GNU_SOURCE, which
- * we do not use otherwise.
-#define HAVE_SENDMMSG
- */
-#if defined(HAVE_SENDMMSG)
-#define _GNU_SOURCE
-#include <sys/socket.h>
-#undef _GNU_SOURCE
-#endif
-
 #include "curl_setup.h"
 
 #ifdef HAVE_NETINET_UDP_H
index 90b6efdadec56f71119a77822cfe000a3fa80f59..5b51243374a24ccfcf121a882cd9415eeb79d959 100644 (file)
@@ -169,6 +169,7 @@ static int get_address_family(curl_socket_t sockfd)
 {
   struct sockaddr addr;
   curl_socklen_t addrlen = sizeof(addr);
+  memset(&addr, 0, sizeof(addr));
   if(getsockname(sockfd, (struct sockaddr *)&addr, &addrlen) == 0)
     return addr.sa_family;
   return AF_UNSPEC;