]> granicus.if.org Git - pdns/commitdiff
dnsdist: Fix potential FD usage count, only warn if limit <= potential
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 20 Oct 2016 12:47:32 +0000 (14:47 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 24 Oct 2016 09:24:12 +0000 (11:24 +0200)
pdns/dnsdist.cc

index 847cdcacf3ef0b4fea1ba5e9cae5c2ab6759702e..e54afb6db6ee44223d45dbe54b14932e76b5f2c7 100644 (file)
@@ -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.");