]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Merge pull request #4285 from rgacogne/dnsdist-unreachable-server
authorPieter Lexis <pieterlexis@users.noreply.github.com>
Fri, 13 Jan 2017 13:28:07 +0000 (14:28 +0100)
committerGitHub <noreply@github.com>
Fri, 13 Jan 2017 13:28:07 +0000 (14:28 +0100)
dnsdist: Handle unreachable servers at startup, reconnect stale sockets

1  2 
pdns/dnsdist-lua.cc
pdns/dnsdist.cc
pdns/dnsdist.hh

Simple merge
diff --cc pdns/dnsdist.cc
index a588e2c9a69f98c48e663658c67178e9e2b0c1f1,300f13241e47e03b1574f2606f65a16903ab2d1e..676030a51fa9ada0a106f5ab0f77f04e09cc0de0
@@@ -493,24 -463,16 +493,31 @@@ try 
    }
    return 0;
  }
 +catch(const std::exception& e)
 +{
 +  errlog("UDP responder thread died because of exception: %s", e.what());
 +  return 0;
 +}
 +catch(const PDNSException& e)
 +{
 +  errlog("UDP responder thread died because of PowerDNS exception: %s", e.reason);
 +  return 0;
 +}
 +catch(...)
 +{
 +  errlog("UDP responder thread died because of an exception: %s", "unknown");
 +  return 0;
 +}
  
DownstreamState::DownstreamState(const ComboAddress& remote_, const ComboAddress& sourceAddr_, unsigned int sourceItf_): remote(remote_), sourceAddr(sourceAddr_), sourceItf(sourceItf_)
void DownstreamState::reconnect()
  {
+   connected = false;
+   if (fd != -1) {
+     /* shutdown() is needed to wake up recv() in the responderThread */
+     shutdown(fd, SHUT_RDWR);
+     close(fd);
+     fd = -1;
+   }
    if (!IsAnyAddress(remote)) {
      fd = SSocket(remote.sin4.sin_family, SOCK_DGRAM, 0);
      if (!IsAnyAddress(sourceAddr)) {
diff --cc pdns/dnsdist.hh
Simple merge