From 393869880dedceb08846c8fde92d5767caae548c Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Tue, 13 Dec 2016 10:35:10 +0100 Subject: [PATCH] dnsdist: Check the vector capacity before creating the TCP worker thread --- pdns/dnsdist-tcp.cc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index 8e30f7dad..69ea93878 100644 --- a/pdns/dnsdist-tcp.cc +++ b/pdns/dnsdist-tcp.cc @@ -94,18 +94,6 @@ void TCPClientCollection::addTCPClientThread() return; } - try { - thread t1(tcpClientThread, pipefds[0]); - t1.detach(); - } - catch(const std::runtime_error& e) { - /* the thread creation failed, don't leak */ - errlog("Error creating a TCP thread: %s", e.what()); - close(pipefds[0]); - close(pipefds[1]); - return; - } - { std::lock_guard lock(d_mutex); @@ -116,6 +104,18 @@ void TCPClientCollection::addTCPClientThread() return; } + try { + thread t1(tcpClientThread, pipefds[0]); + t1.detach(); + } + catch(const std::runtime_error& e) { + /* the thread creation failed, don't leak */ + errlog("Error creating a TCP thread: %s", e.what()); + close(pipefds[0]); + close(pipefds[1]); + return; + } + d_tcpclientthreads.push_back(pipefds[1]); } -- 2.40.0