]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Account for more than one socket per backend
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 5 Mar 2018 09:49:52 +0000 (10:49 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 6 Mar 2018 16:02:51 +0000 (17:02 +0100)
pdns/dnsdist.cc

index 71698f21a53c48aeb4a8a122087edec1c5cd2596..449779a27af7c53a3160508bec52f6ef8d908aca 100644 (file)
@@ -1985,7 +1985,15 @@ static void checkFileDescriptorsLimits(size_t udpBindsCount, size_t tcpBindsCoun
 {
   /* stdin, stdout, stderr */
   size_t requiredFDsCount = 3;
-  size_t backendsCount = g_dstates.getCopy().size();
+  const auto backends = g_dstates.getCopy();
+  /* UDP sockets to backends */
+  size_t backendUDPSocketsCount = 0;
+  for (const auto& backend : backends) {
+    backendUDPSocketsCount += backend->fds.size();
+  }
+  requiredFDsCount += backendUDPSocketsCount;
+  /* TCP sockets to backends */
+  requiredFDsCount += (backends.size() * g_maxTCPClientThreads);
   /* listening sockets */
   requiredFDsCount += udpBindsCount;
   requiredFDsCount += tcpBindsCount;
@@ -1993,10 +2001,6 @@ static void checkFileDescriptorsLimits(size_t udpBindsCount, size_t tcpBindsCoun
   requiredFDsCount += g_maxTCPClientThreads;
   /* max pipes for communicating between TCP acceptors and client threads */
   requiredFDsCount += (g_maxTCPClientThreads * 2);
-  /* UDP sockets to backends */
-  requiredFDsCount += backendsCount;
-  /* TCP sockets to backends */
-  requiredFDsCount += (backendsCount * g_maxTCPClientThreads);
   /* max TCP queued connections */
   requiredFDsCount += g_maxTCPQueuedConnections;
   /* DelayPipe pipe */