From: Otto Date: Fri, 6 Aug 2021 08:26:41 +0000 (+0200) Subject: Move MacOS to kqueue and assorted compile fixes X-Git-Tag: dnsdist-1.7.0-alpha1~72^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F10634%2Fhead;p=thirdparty%2Fpdns.git Move MacOS to kqueue and assorted compile fixes --- diff --git a/m4/pdns_check_os.m4 b/m4/pdns_check_os.m4 index 93aa96a7f6..bb5f2fd7f3 100644 --- a/m4/pdns_check_os.m4 +++ b/m4/pdns_check_os.m4 @@ -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]) diff --git a/pdns/kqueuemplexer.cc b/pdns/kqueuemplexer.cc index cb8a3efb4e..505394f83a 100644 --- a/pdns/kqueuemplexer.cc +++ b/pdns/kqueuemplexer.cc @@ -28,7 +28,7 @@ #include #include "misc.hh" #include -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) #include #endif #include diff --git a/pdns/lwres.cc b/pdns/lwres.cc index 7bec6f8ae4..1441a39edb 100644 --- a/pdns/lwres.cc +++ b/pdns/lwres.cc @@ -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(g_networkTimeoutMsec) % 1000 * 1000}; Socket s(ip.sin4.sin_family, SOCK_STREAM); s.setNonBlocking(); diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 172421a34a..49dc5deffa 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -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(tv.tv_sec)); } - snprintf(buf + len, sz - len, ".%03ld", tv.tv_usec / 1000); + snprintf(buf + len, sz - len, ".%03ld", static_cast(tv.tv_usec) / 1000); return buf; } diff --git a/pdns/rec-carbon.cc b/pdns/rec-carbon.cc index 9b55e7b6bf..479d12ace9 100644 --- a/pdns/rec-carbon.cc +++ b/pdns/rec-carbon.cc @@ -51,7 +51,7 @@ try Socket s(remote.sin4.sin_family, SOCK_STREAM); s.setNonBlocking(); std::shared_ptr tlsCtx{nullptr}; - const struct timeval timeout{g_networkTimeoutMsec / 1000, g_networkTimeoutMsec % 1000 * 1000}; + const struct timeval timeout{g_networkTimeoutMsec / 1000, static_cast(g_networkTimeoutMsec) % 1000 * 1000}; auto handler = std::make_shared("", 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 diff --git a/pdns/recursordist/Makefile.am b/pdns/recursordist/Makefile.am index 2f6c29dd25..8309c9f729 100644 --- a/pdns/recursordist/Makefile.am +++ b/pdns/recursordist/Makefile.am @@ -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 diff --git a/pdns/ws-recursor.cc b/pdns/ws-recursor.cc index 56f9722dc5..e0cb913072 100644 --- a/pdns/ws-recursor.cc +++ b/pdns/ws-recursor.cc @@ -1271,7 +1271,7 @@ void AsyncWebServer::serveConnection(std::shared_ptr 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(g_networkTimeoutMsec) % 1000 * 1000}; std::shared_ptr tlsCtx{nullptr}; auto handler = std::make_shared("", client->releaseHandle(), timeout, tlsCtx, time(nullptr));