]> granicus.if.org Git - pdns/commitdiff
dnsdist: Add an optional 'checkTimeout' parameter to 'newServer()'
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 3 Jan 2019 15:57:44 +0000 (16:57 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 3 Jan 2019 15:57:44 +0000 (16:57 +0100)
pdns/dnsdist-lua.cc
pdns/dnsdist.cc
pdns/dnsdist.hh
pdns/dnsdistdist/docs/reference/config.rst

index 6b46afbc10741f22a47f3a6a7be32435c630f465..8452f2a2eeb0e1ad40f4b3212f8a8d6de07ad1a8 100644 (file)
@@ -336,6 +336,10 @@ void setupLuaConfig(bool client)
                          ret->checkFunction= boost::get<DownstreamState::checkfunc_t>(vars["checkFunction"]);
                        }
 
+                       if(vars.count("checkTimeout")) {
+                         ret->checkTimeout = std::stoi(boost::get<string>(vars["checkTimeout"]));
+                       }
+
                        if(vars.count("setCD")) {
                          ret->setCD=boost::get<bool>(vars["setCD"]);
                        }
index 915d90484fbcbae9e5f0e96f1e26d7376f25ec42..bfe3fb43fbfe73b813cb81e6a85670418f49f30a 100644 (file)
@@ -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;
index c4ae2bac3ac5021cc9dec6859dbec435745096c9..95ef31c244d629dbf208e5f6a28c8744d4ee21e0 100644 (file)
@@ -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;
index fd045b5b4658b7db55c194908677a60b7745d1ee..c2f0a98e4c3f3edd7de232b8c2418eac98dde3df 100644 (file)
@@ -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