From: Pieter Lexis Date: Fri, 13 Jan 2017 13:28:07 +0000 (+0100) Subject: Merge pull request #4285 from rgacogne/dnsdist-unreachable-server X-Git-Tag: rec-4.1.0-alpha1~334 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5219a1cb1e388ab00c7c5e261b22b58e7df9c8dd;p=thirdparty%2Fpdns.git Merge pull request #4285 from rgacogne/dnsdist-unreachable-server dnsdist: Handle unreachable servers at startup, reconnect stale sockets --- 5219a1cb1e388ab00c7c5e261b22b58e7df9c8dd diff --cc pdns/dnsdist.cc index a588e2c9a6,300f13241e..676030a51f --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@@ -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)) {