From: Remi Gacogne Date: Thu, 3 Jan 2019 15:57:44 +0000 (+0100) Subject: dnsdist: Add an optional 'checkTimeout' parameter to 'newServer()' X-Git-Tag: rec-4.2.0-alpha1~38^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b7e6f4a1c9fef9b637b4f9b499cdb4b11ee8e63c;p=pdns dnsdist: Add an optional 'checkTimeout' parameter to 'newServer()' --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 6b46afbc1..8452f2a2e 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -336,6 +336,10 @@ void setupLuaConfig(bool client) ret->checkFunction= boost::get(vars["checkFunction"]); } + if(vars.count("checkTimeout")) { + ret->checkTimeout = std::stoi(boost::get(vars["checkTimeout"])); + } + if(vars.count("setCD")) { ret->setCD=boost::get(vars["setCD"]); } diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 915d90484..bfe3fb43f 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -1763,7 +1763,7 @@ try return false; } - int ret=waitForRWData(sock.getHandle(), true, 1, 0); + int ret = waitForRWData(sock.getHandle(), true, /* ms to seconds */ ds.checkTimeout / 1000, /* remaining ms to us */ (ds.checkTimeout % 1000) * 1000); if(ret < 0 || !ret) { // error, timeout, both are down! if (ret < 0) { ret = errno; diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index c4ae2bac3..95ef31c24 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -707,6 +707,7 @@ struct DownstreamState const unsigned int sourceItf{0}; uint16_t retries{5}; uint16_t xpfRRCode{0}; + uint16_t checkTimeout{1000}; /* in milliseconds */ uint8_t currentCheckFailures{0}; uint8_t maxCheckFailures{1}; StopWatch sw; diff --git a/pdns/dnsdistdist/docs/reference/config.rst b/pdns/dnsdistdist/docs/reference/config.rst index fd045b5b4..c2f0a98e4 100644 --- a/pdns/dnsdistdist/docs/reference/config.rst +++ b/pdns/dnsdistdist/docs/reference/config.rst @@ -310,6 +310,8 @@ Servers - Added ``sockets`` to server_table - Added ``checkFunction`` to server_table + .. versionchanged:: 1.3.4 + - Added ``checkTimeout`` to server_table Add a new backend server. Call this function with either a string:: @@ -338,6 +340,7 @@ Servers checkName=STRING, -- Use STRING as QNAME in the health-check query, default: "a.root-servers.net." checkType=STRING, -- Use STRING as QTYPE in the health-check query, default: "A" checkFunction=FUNCTION -- Use this function to dynamically set the QNAME, QTYPE and QCLASS to use in the health-check query (see :ref:`Healthcheck`) + checkTimeout=NUM -- The timeout (in milliseconds) of a health-check query, default: 1000 (1s) setCD=BOOL, -- Set the CD (Checking Disabled) flag in the health-check query, default: false maxCheckFailures=NUM, -- Allow NUM check failures before declaring the backend down, default: 1 mustResolve=BOOL, -- Set to true when the health check MUST return a NOERROR RCODE and an answer