From: Remi Gacogne Date: Thu, 20 Oct 2016 12:47:32 +0000 (+0200) Subject: dnsdist: Fix potential FD usage count, only warn if limit <= potential X-Git-Tag: dnsdist-1.1.0-beta2~65^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9fcd6adb629dc7a70a1493bf845131e802fb6090;p=thirdparty%2Fpdns.git dnsdist: Fix potential FD usage count, only warn if limit <= potential --- diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 847cdcacf3..e54afb6db6 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -1425,6 +1425,7 @@ static void checkFileDescriptorsLimits(size_t udpBindsCount, size_t tcpBindsCoun /* stdin, stdout, stderr */ size_t requiredFDsCount = 3; size_t backendsCount = g_dstates.getCopy().size(); + /* listening sockets */ requiredFDsCount += udpBindsCount; requiredFDsCount += tcpBindsCount; /* max TCP connections currently served */ @@ -1436,7 +1437,7 @@ static void checkFileDescriptorsLimits(size_t udpBindsCount, size_t tcpBindsCoun /* TCP sockets to backends */ requiredFDsCount += (backendsCount * g_maxTCPClientThreads); /* max TCP queued connections */ - requiredFDsCount += (tcpBindsCount * g_maxTCPQueuedConnections); + requiredFDsCount += g_maxTCPQueuedConnections; /* DelayPipe pipe */ requiredFDsCount += 2; /* syslog socket */ @@ -1451,7 +1452,7 @@ static void checkFileDescriptorsLimits(size_t udpBindsCount, size_t tcpBindsCoun requiredFDsCount++; struct rlimit rl; getrlimit(RLIMIT_NOFILE, &rl); - if (((rl.rlim_cur * 3) / 4) < requiredFDsCount) { + if (rl.rlim_cur <= requiredFDsCount) { warnlog("Warning, this configuration can use more than %d file descriptors, web server and console connections not included, and the current limit is %d.", std::to_string(requiredFDsCount), std::to_string(rl.rlim_cur)); #ifdef HAVE_SYSTEMD warnlog("You can increase this value by using LimitNOFILE= in the systemd unit file or ulimit.");