]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Move MacOS to kqueue and assorted compile fixes 10634/head
authorOtto <otto.moerbeek@open-xchange.com>
Fri, 6 Aug 2021 08:26:41 +0000 (10:26 +0200)
committerOtto <otto.moerbeek@open-xchange.com>
Fri, 6 Aug 2021 08:26:41 +0000 (10:26 +0200)
m4/pdns_check_os.m4
pdns/kqueuemplexer.cc
pdns/lwres.cc
pdns/pdns_recursor.cc
pdns/rec-carbon.cc
pdns/recursordist/Makefile.am
pdns/ws-recursor.cc

index 93aa96a7f681e9b35d2b58ae22e04bc7ff918b61..bb5f2fd7f380c69aedc1e3e63084dbb936bc592e 100644 (file)
@@ -20,6 +20,7 @@ AC_DEFUN([PDNS_CHECK_OS],[
     ;;
   darwin*)
     CXXFLAGS="-D__APPLE_USE_RFC_3542 -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE $CXXFLAGS"
+    have_darwin="yes"
     ;;
   freebsd*)
     THREADFLAGS="-pthread"
@@ -38,6 +39,7 @@ AC_DEFUN([PDNS_CHECK_OS],[
   AM_CONDITIONAL([HAVE_FREEBSD], [test "x$have_freebsd" = "xyes"])
   AM_CONDITIONAL([HAVE_OPENBSD], [test "x$have_openbsd" = "xyes"])
   AM_CONDITIONAL([HAVE_LINUX], [test "x$have_linux" = "xyes"])
+  AM_CONDITIONAL([HAVE_DARWIN], [test "x$have_darwin" = "xyes"])
   AM_CONDITIONAL([HAVE_SOLARIS], [test "x$have_solaris" = "xyes"])
 
   AC_MSG_CHECKING([whether -latomic is needed for __atomic builtins])
index cb8a3efb4e7a4e5c7acc700eb90f922f7ec29444..505394f83a7627f2e8386e6c5514af85adb4f463 100644 (file)
@@ -28,7 +28,7 @@
 #include <unistd.h>
 #include "misc.hh"
 #include <sys/types.h>
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
 #include <sys/event.h>
 #endif
 #include <sys/time.h>
index 7bec6f8ae47c0d8e439364463fbf6bb6a1f6b870..1441a39edbaf28ca86b6b6cc3d0e44c1c8daed91 100644 (file)
@@ -343,7 +343,7 @@ LWResult::Result asyncresolve(const ComboAddress& ip, const DNSName& domain, int
   }
   else {
     try {
-      const struct timeval timeout{ g_networkTimeoutMsec / 1000, g_networkTimeoutMsec % 1000 * 1000};
+      const struct timeval timeout{ g_networkTimeoutMsec / 1000, static_cast<suseconds_t>(g_networkTimeoutMsec) % 1000 * 1000};
 
       Socket s(ip.sin4.sin_family, SOCK_STREAM);
       s.setNonBlocking();
index 172421a34ad939a62701a39e23fec37e6dde5590..49dc5deffae987f3b615cb79028ad4d4396a8c8f 100644 (file)
@@ -5618,10 +5618,10 @@ static const char* toTimestampStringMilli(const struct timeval& tv, char *buf, s
   struct tm tm;
   size_t len = strftime(buf, sz, s_timestampFormat.c_str(), localtime_r(&tv.tv_sec, &tm));
   if (len == 0) {
-    len = snprintf(buf, sz, "%lld", (long long) tv.tv_sec);
+    len = snprintf(buf, sz, "%lld", static_cast<long long>(tv.tv_sec));
   }
 
-  snprintf(buf + len, sz - len, ".%03ld", tv.tv_usec / 1000);
+  snprintf(buf + len, sz - len, ".%03ld", static_cast<long>(tv.tv_usec) / 1000);
   return buf;
 }
 
index 9b55e7b6bfeeafc344520a1da85db5a33dee82b9..479d12ace97e89923adabc30e8acfb2b8e83ab7b 100644 (file)
@@ -51,7 +51,7 @@ try
     Socket s(remote.sin4.sin_family, SOCK_STREAM);
     s.setNonBlocking();
     std::shared_ptr<TLSCtx> tlsCtx{nullptr};
-    const struct timeval timeout{g_networkTimeoutMsec / 1000, g_networkTimeoutMsec % 1000 * 1000};
+    const struct timeval timeout{g_networkTimeoutMsec / 1000, static_cast<suseconds_t>(g_networkTimeoutMsec) % 1000 * 1000};
     auto handler = std::make_shared<TCPIOHandler>("", s.releaseHandle(), timeout, tlsCtx, time(nullptr));
      handler->tryConnect(SyncRes::s_tcp_fast_open_connect, remote);// we do the connect so the first attempt happens while we gather stats
 
index 2f6c29dd251ace08fa8cee57d464e62fa18ce684..8309c9f72954772a004574c606eedd0cc53f9c1c 100644 (file)
@@ -397,6 +397,11 @@ pdns_recursor_SOURCES += kqueuemplexer.cc
 testrunner_SOURCES += kqueuemplexer.cc
 endif
 
+if HAVE_DARWIN
+pdns_recursor_SOURCES += kqueuemplexer.cc
+testrunner_SOURCES += kqueuemplexer.cc
+endif
+
 if HAVE_LINUX
 pdns_recursor_SOURCES += epollmplexer.cc
 testrunner_SOURCES += epollmplexer.cc
index 56f9722dc55d86d48ef8ea9c3d6552dd57428de1..e0cb913072a74c432fa222cf9541a0b7cd381467 100644 (file)
@@ -1271,7 +1271,7 @@ void AsyncWebServer::serveConnection(std::shared_ptr<Socket> client) const {
     yarl.initialize(&req);
     client->setNonBlocking();
 
-    const struct timeval timeout{g_networkTimeoutMsec / 1000, g_networkTimeoutMsec % 1000 * 1000};
+    const struct timeval timeout{g_networkTimeoutMsec / 1000, static_cast<suseconds_t>(g_networkTimeoutMsec) % 1000 * 1000};
     std::shared_ptr<TLSCtx> tlsCtx{nullptr};
     auto handler = std::make_shared<TCPIOHandler>("", client->releaseHandle(), timeout, tlsCtx, time(nullptr));