]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Move TCPClientCollection ctor to dnsdist-tcp.cc
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 8 Feb 2021 14:35:00 +0000 (15:35 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 2 Mar 2021 09:46:20 +0000 (10:46 +0100)
pdns/dnsdist-tcp.cc
pdns/dnsdist.hh

index a17c5acf62eecbf98b7721f90eae5562accae1e9..e4840fc9e1626e15956c7df5211a25a286aef275 100644 (file)
@@ -190,6 +190,32 @@ std::shared_ptr<TCPConnectionToBackend> IncomingTCPConnectionState::getDownstrea
 
 static void tcpClientThread(int pipefd);
 
+TCPClientCollection::TCPClientCollection(size_t maxThreads, bool useSinglePipe): d_tcpclientthreads(maxThreads), d_maxthreads(maxThreads), d_singlePipe{-1,-1}, d_useSinglePipe(useSinglePipe)
+{
+  if (d_useSinglePipe) {
+    if (pipe(d_singlePipe) < 0) {
+      int err = errno;
+      throw std::runtime_error("Error creating the TCP single communication pipe: " + stringerror(err));
+    }
+
+    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: " + stringerror(err));
+    }
+
+    if (!setNonBlocking(d_singlePipe[1])) {
+      int err = errno;
+      close(d_singlePipe[0]);
+      close(d_singlePipe[1]);
+      throw std::runtime_error("Error setting the TCP single communication pipe non-blocking: " + stringerror(err));
+    }
+
+    setPipeBufferSize(d_singlePipe[0], 1048576);
+  }
+}
+
 void TCPClientCollection::addTCPClientThread()
 {
   int pipefds[2] = { -1, -1};
index a98c7324d3732fc383a83576f041772a594606ef..81b1b3af52ded2d28d56a112fc40b142bfb7078b 100644 (file)
@@ -831,30 +831,7 @@ class TCPClientCollection {
   const bool d_useSinglePipe;
 public:
 
-  TCPClientCollection(size_t maxThreads, bool useSinglePipe=false): d_tcpclientthreads(maxThreads), d_maxthreads(maxThreads), d_singlePipe{-1,-1}, d_useSinglePipe(useSinglePipe)
-
-  {
-    if (d_useSinglePipe) {
-      if (pipe(d_singlePipe) < 0) {
-        int err = errno;
-        throw std::runtime_error("Error creating the TCP single communication pipe: " + stringerror(err));
-      }
-
-      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: " + stringerror(err));
-      }
-
-      if (!setNonBlocking(d_singlePipe[1])) {
-        int err = errno;
-        close(d_singlePipe[0]);
-        close(d_singlePipe[1]);
-        throw std::runtime_error("Error setting the TCP single communication pipe non-blocking: " + stringerror(err));
-      }
-    }
-  }
+  TCPClientCollection(size_t maxThreads, bool useSinglePipe=false);
   int getThread()
   {
     if (d_numthreads == 0) {