From 3b07fd1b5888aec853e98da89edc016d6c465132 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Thu, 21 Mar 2019 18:36:33 +0100 Subject: [PATCH] dnsdist: Make sure that the TCP distribution pipes are non-blocking --- pdns/dnsdist-tcp.cc | 7 +++++++ pdns/dnsdist.hh | 8 ++++++++ 2 files changed, 15 insertions(+) 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]); -- 2.47.2