From: Remi Gacogne Date: Fri, 24 Apr 2020 10:45:45 +0000 (+0200) Subject: dnsdist: Gracefully handle a failure to remove FD on (re)-connection X-Git-Tag: dnsdist-1.5.0-rc2~10^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F9057%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Gracefully handle a failure to remove FD on (re)-connection When more than one socket per backend is used, we might not have added all the socket descriptors to the multiplexer and that's fine. --- diff --git a/pdns/dnsdistdist/dnsdist-backend.cc b/pdns/dnsdistdist/dnsdist-backend.cc index 606977c098..fbce5dd708 100644 --- a/pdns/dnsdistdist/dnsdist-backend.cc +++ b/pdns/dnsdistdist/dnsdist-backend.cc @@ -79,8 +79,14 @@ bool DownstreamState::reconnect() for (auto& fd : sockets) { if (fd != -1) { if (sockets.size() > 1) { - std::lock_guard lock(socketsLock); - mplexer->removeReadFD(fd); + try { + std::lock_guard lock(socketsLock); + mplexer->removeReadFD(fd); + } + catch (const FDMultiplexerException& e) { + /* some sockets might not have been added to the multiplexer + yet, that's fine */ + } } /* shutdown() is needed to wake up recv() in the responderThread */ shutdown(fd, SHUT_RDWR);