From: Remi Gacogne Date: Tue, 13 Dec 2016 09:35:10 +0000 (+0100) Subject: dnsdist: Check the vector capacity before creating the TCP worker thread X-Git-Tag: dnsdist-1.1.0-beta2~1^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F4764%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Check the vector capacity before creating the TCP worker thread --- diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index 8e30f7dad2..69ea938785 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]); }