From: Remi Gacogne Date: Thu, 21 Mar 2019 17:36:33 +0000 (+0100) Subject: dnsdist: Make sure that the TCP distribution pipes are non-blocking X-Git-Tag: dnsdist-1.4.0-alpha1~25^2~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3b07fd1b5888aec853e98da89edc016d6c465132;p=thirdparty%2Fpdns.git dnsdist: Make sure that the TCP distribution pipes are non-blocking --- diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index 35f7c19a86..9889583e98 100644 --- a/pdns/dnsdist-tcp.cc +++ b/pdns/dnsdist-tcp.cc @@ -209,6 +209,13 @@ void TCPClientCollection::addTCPClientThread() return; } + if (!setNonBlocking(pipefds[0])) { + close(pipefds[0]); + close(pipefds[1]); + errlog("Error setting the TCP thread communication pipe non-blocking: %s", strerror(errno)); + return; + } + if (!setNonBlocking(pipefds[1])) { close(pipefds[0]); close(pipefds[1]); diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index eed5d46940..f76888c09c 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -636,6 +636,14 @@ public: if (pipe(d_singlePipe) < 0) { throw std::runtime_error("Error creating the TCP single communication pipe: " + string(strerror(errno))); } + + if (!setNonBlocking(d_singlePipe[0])) { + int err = errno; + close(d_singlePipe[0]); + close(d_singlePipe[1]); + throw std::runtime_error("Error setting the TCP single communication pipe non-blocking: " + string(strerror(err))); + } + if (!setNonBlocking(d_singlePipe[1])) { int err = errno; close(d_singlePipe[0]);