From: Otto Date: Tue, 24 Aug 2021 09:19:32 +0000 (+0200) Subject: Cleanup and docs X-Git-Tag: rec-4.6.0-alpha1~2^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80252248b2cad583a6e73577c179747681215ede;p=thirdparty%2Fpdns.git Cleanup and docs --- diff --git a/pdns/lwres.cc b/pdns/lwres.cc index 601586471f..1dc559921d 100644 --- a/pdns/lwres.cc +++ b/pdns/lwres.cc @@ -235,7 +235,7 @@ static void logIncomingResponse(const std::shared_ptr& srcmask, boost::optional context, const std::shared_ptr>>& outgoingLoggers, const std::shared_ptr>>& fstrmLoggers, const std::set& exportTypes, LWResult *lwr, bool* chained, TCPOutConnectionManager::Connection& connection) +static LWResult::Result asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, struct timeval* now, boost::optional& srcmask, boost::optional context, const std::shared_ptr>>& outgoingLoggers, const std::shared_ptr>>& fstrmLoggers, const std::set& exportTypes, LWResult *lwr, bool* chained, TCPOutConnectionManager::Connection& connection) { size_t len; size_t bufsize=g_outgoingEDNSBufsize; @@ -347,6 +347,10 @@ static LWResult::Result asyncresolve1(const ComboAddress& ip, const DNSName& dom else { try { while (true) { + // If we get a new (not re-used) TCP connection that does not + // work, we give up. For reused connections, we assume the + // peer has closed it on error, so we retry. At some point we + // *will* get a new connection, so this loop is not endless. bool isNew = false; connection = t_tcp_manager.get(ip); if (!connection.d_handler) { @@ -424,7 +428,6 @@ static LWResult::Result asyncresolve1(const ComboAddress& ip, const DNSName& dom } buf.resize(len); memcpy(buf.data(), packet.data(), len); - //handler->close(); ret = LWResult::Result::Success; break; } @@ -548,11 +551,11 @@ static LWResult::Result asyncresolve1(const ComboAddress& ip, const DNSName& dom LWResult::Result asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, struct timeval* now, boost::optional& srcmask, boost::optional context, const std::shared_ptr>>& outgoingLoggers, const std::shared_ptr>>& fstrmLoggers, const std::set& exportTypes, LWResult *lwr, bool* chained) { TCPOutConnectionManager::Connection connection; - auto ret = asyncresolve1(ip, domain, type,doTCP, sendRDQuery, EDNS0Level, now, srcmask, context, outgoingLoggers, fstrmLoggers, exportTypes, lwr, chained, connection); + auto ret = asyncresolve(ip, domain, type,doTCP, sendRDQuery, EDNS0Level, now, srcmask, context, outgoingLoggers, fstrmLoggers, exportTypes, lwr, chained, connection); if (doTCP) { if (!lwr->d_validpacket) { - ret = asyncresolve1(ip, domain, type,doTCP, sendRDQuery, EDNS0Level, now, srcmask, context, outgoingLoggers, fstrmLoggers, exportTypes, lwr, chained, connection); + ret = asyncresolve(ip, domain, type,doTCP, sendRDQuery, EDNS0Level, now, srcmask, context, outgoingLoggers, fstrmLoggers, exportTypes, lwr, chained, connection); } if (connection.d_handler && lwr->d_validpacket) { t_tcp_manager.store(ip, connection); diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index b16c9dde1a..10b3219b3e 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -5942,10 +5942,10 @@ int main(int argc, char **argv) ::arg().setSwitch("dot-to-port-853", "Force DoT connection to target port 853 if DoT compiled in")="yes"; ::arg().set("dot-to-auth-names", "Use DoT to authoritative servers with these names or suffixes")=""; - ::arg().set("tcpout-maxidle-ms", "Maximum time TCP connections are left idle in milliseconds or 0 if no limit") = "10000"; - ::arg().set("tcpout-maxidle-per-auth", "Maximum number of idle TCP connections to a specific IP per thread, 0 means do not keep idle connections open") = "10"; - ::arg().set("tcpout-max-queries", "Maximum total number of queries per connection, 0 means no limit") = "0"; - ::arg().set("tcpout-maxidle-per-thread", "Maximum number of idle TCP connections per thread") = "100"; + ::arg().set("tcpout-maxidle-ms", "Time TCP/DoT connections are left idle in milliseconds or 0 if no limit") = "10000"; + ::arg().set("tcpout-maxidle-per-auth", "Maximum number of idle TCP/DoT connections to a specific IP per thread, 0 means do not keep idle connections open") = "10"; + ::arg().set("tcpout-max-queries", "Maximum total number of queries per TCP/DoT connection, 0 means no limit") = "0"; + ::arg().set("tcpout-maxidle-per-thread", "Maximum number of idle TCP/DoT connections per thread") = "100"; ::arg().setCmd("help","Provide a helpful message"); ::arg().setCmd("version","Print version string"); diff --git a/pdns/recursordist/docs/settings.rst b/pdns/recursordist/docs/settings.rst index 0023719f5c..530f44e2be 100644 --- a/pdns/recursordist/docs/settings.rst +++ b/pdns/recursordist/docs/settings.rst @@ -1887,6 +1887,43 @@ The numerical value supplied is used as the queue size, 0 meaning disabled. See Enable TCP Fast Open Connect support, if available, on the outgoing connections to authoritative servers. See :ref:`tcp-fast-open-support`. +``tcpout-maxidle-ms`` +--------------------- +.. versionadded:: 4.6.0 + +- Integer +- Default : 10000 + +Time outgoing TCP/DoT connections are left idle in milliseconds or 0 if no limit. After having been idle for this time, the connection is elegible for closing. + +``tcpout-maxidle-per-auth`` +--------------------------- +.. versionadded:: 4.6.0 + +- Integer +- Default : 10 + +Maximum number of idle outgoing TCP/DoT connections to a specific IP per thread, 0 means do not keep idle connections open. + +``tcpout-max-queries`` +---------------------- +- Integer +- Default : 0 + +Maximum total number of queries per outgoing TCP/DoT connection, 0 means no limit. After this number of queries, the concection is +closed and a new one will be created if needed. + +.. versionadded:: 4.6.0 + +``tcpout-maxidle-per-thread`` +----------------------------- +.. versionadded:: 4.6.0 + +- Integer +- Default : 0 + +Maximum number of idle outgoing TCP/DoT connections per thread, 0 means do not keep idle connections open. + .. _setting-threads: ``threads`` diff --git a/pdns/recursordist/rec-tcpout.hh b/pdns/recursordist/rec-tcpout.hh index 3b17da1b6c..f342a86b61 100644 --- a/pdns/recursordist/rec-tcpout.hh +++ b/pdns/recursordist/rec-tcpout.hh @@ -35,7 +35,7 @@ public: static size_t maxIdlePerAuth; // Max total number of queries to handle per connection, 0 is no max static size_t maxQueries; - // Per thread max # of idle connections, here 0 means a real limit + // Per thread max # of idle connections, 0 means no idle connections will be kept open static size_t maxIdlePerThread; struct Connection