From cd73ceebff1b805de167ad23198def0c8a59d786 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Mon, 5 Mar 2018 10:49:52 +0100 Subject: [PATCH] dnsdist: Account for more than one socket per backend --- pdns/dnsdist.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 71698f21a..449779a27 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -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 */ -- 2.40.0