From: Remi Gacogne Date: Thu, 24 May 2018 15:35:39 +0000 (+0200) Subject: dnsdist: Don't reconnect the socket on healthcheck failure X-Git-Tag: dnsdist-1.3.1~56^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1b12622540e11f6f8547f5af5cc5db67890cad2e;p=pdns dnsdist: Don't reconnect the socket on healthcheck failure --- diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index aeec6f39b..73b013655 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -1077,7 +1077,7 @@ bool processResponse(LocalStateHolder >& local return true; } -static ssize_t udpClientSendRequestToBackend(DownstreamState* ss, const int sd, const char* request, const size_t requestLen) +static ssize_t udpClientSendRequestToBackend(DownstreamState* ss, const int sd, const char* request, const size_t requestLen, bool healthCheck=false) { ssize_t result; @@ -1098,8 +1098,11 @@ static ssize_t udpClientSendRequestToBackend(DownstreamState* ss, const int sd, vinfolog("Error sending request to backend %s: %d", ss->remote.toStringWithPort(), savederrno); /* This might sound silly, but on Linux send() might fail with EINVAL - if the interface the socket was bound to doesn't exist anymore. */ - if (savederrno == EINVAL) { + if the interface the socket was bound to doesn't exist anymore. + We don't want to reconnect the real socket if the healthcheck failed, + because it's not using the same socket. + */ + if (!healthCheck && (savederrno == EINVAL || savederrno == ENODEV)) { ss->reconnect(); } } @@ -1679,7 +1682,7 @@ try sock.bind(ds.sourceAddr); } sock.connect(ds.remote); - ssize_t sent = udpClientSendRequestToBackend(&ds, sock.getHandle(), (char*)&packet[0], packet.size()); + ssize_t sent = udpClientSendRequestToBackend(&ds, sock.getHandle(), (char*)&packet[0], packet.size(), true); if (sent < 0) { int ret = errno; if (g_verboseHealthChecks)