[pdns-recursor/el6] Add upstream patch to fix rhbz#1063304

Morten Stevens mstevens at fedoraproject.org
Mon Feb 10 14:08:48 UTC 2014


commit e7ee228d790ff3182964a6426cee7abd2f5450d2
Author: Morten Stevens <mstevens at imt-systems.com>
Date:   Mon Feb 10 15:09:24 2014 +0100

    Add upstream patch to fix rhbz#1063304

 pdns-recursor-fixmthreads.patch |   99 +++++++++++++++++++++++++++++++++++++++
 pdns-recursor.spec              |    7 ++-
 2 files changed, 105 insertions(+), 1 deletions(-)
---
diff --git a/pdns-recursor-fixmthreads.patch b/pdns-recursor-fixmthreads.patch
new file mode 100644
index 0000000..ea07e85
--- /dev/null
+++ b/pdns-recursor-fixmthreads.patch
@@ -0,0 +1,99 @@
+From e24b124a4c7b49f38ff8bcf6926cd69077d16ad8 Mon Sep 17 00:00:00 2001
+From: bert hubert <bert.hubert at netherlabs.nl>
+Date: Thu, 6 Feb 2014 12:48:23 +0100
+Subject: [PATCH] make sure we don't exceed the number of available
+ filedescriptors for mthreads. You can still overshoot a little bit, but not
+ all mthreads will be using an fd.
+
+(includes '_actually_ raise the limit to the max if impossible to fit within the hard limit')
+---
+ pdns/misc.cc          | 22 +++++++++++++++++++++-
+ pdns/misc.hh          |  2 ++
+ pdns/pdns_recursor.cc | 17 ++++++++++++++++-
+ 3 files changed, 39 insertions(+), 2 deletions(-)
+
+diff --git a/pdns/misc.cc b/pdns/misc.cc
+index 1032ada..0b5c17f 100644
+--- a/pdns/misc.cc
++++ b/pdns/misc.cc
+@@ -1,6 +1,6 @@
+ /*
+     PowerDNS Versatile Database Driven Nameserver
+-    Copyright (C) 2002 - 2010  PowerDNS.COM BV
++    Copyright (C) 2002 - 2014  PowerDNS.COM BV
+ 
+     This program is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License version 2
+@@ -22,6 +22,7 @@
+ #include <netdb.h>
+ #include <sys/time.h>
+ #include <time.h>
++#include <sys/resource.h>
+ #include <netinet/in.h>
+ #include <unistd.h>
+ #endif // WIN32
+@@ -783,3 +784,22 @@ bool stringfgets(FILE* fp, std::string& line)
+   if(regcomp(&d_preg, expr.c_str(), REG_ICASE|REG_NOSUB|REG_EXTENDED))
+     throw AhuException("Regular expression did not compile");
+ }
++
++unsigned int getFilenumLimit(bool hardOrSoft)
++{
++  struct rlimit rlim;
++  if(getrlimit(RLIMIT_NOFILE, &rlim) < 0)
++    unixDie("Requesting number of available file descriptors");
++  return hardOrSoft ? rlim.rlim_max : rlim.rlim_cur;
++}
++
++void setFilenumLimit(unsigned int lim)
++{
++  struct rlimit rlim;
++
++  if(getrlimit(RLIMIT_NOFILE, &rlim) < 0)
++    unixDie("Requesting number of available file descriptors");
++  rlim.rlim_cur=lim;
++  if(setrlimit(RLIMIT_NOFILE, &rlim) < 0)
++    unixDie("Setting number of available file descriptors");
++}
+diff --git a/pdns/misc.hh b/pdns/misc.hh
+index 7b1489a..376aea6 100644
+--- a/pdns/misc.hh
++++ b/pdns/misc.hh
+@@ -484,4 +484,6 @@ private:
+   regex_t d_preg;
+ };
+ 
++unsigned int getFilenumLimit(bool hardOrSoft=0);
++void setFilenumLimit(unsigned int lim);
+ #endif
+diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc
+index dcadf1b..6d060cc 100644
+--- a/pdns/pdns_recursor.cc
++++ b/pdns/pdns_recursor.cc
+@@ -1837,7 +1837,22 @@ int serviceMain(int argc, char*argv[])
+   
+   g_tcpTimeout=::arg().asNum("client-tcp-timeout");
+   g_maxTCPPerClient=::arg().asNum("max-tcp-per-client");
+-  g_maxMThreads=::arg().asNum("max-mthreads");
++  g_maxMThreads=::arg().asNum("max-mthreads");	
++  unsigned int availFDs=getFilenumLimit();
++  if(g_maxMThreads * g_numThreads > availFDs) {
++    if(getFilenumLimit(true) >= g_maxMThreads * g_numThreads) {
++      setFilenumLimit(g_maxMThreads * g_numThreads);
++      L<<Logger::Warning<<"Raised soft limit on number of filedescriptors to "<<g_maxMThreads * g_numThreads<<" to match max-mthreads and threads settings"<<endl;
++    }
++    else {
++      int newval = getFilenumLimit(true) / g_numThreads;
++      L<<Logger::Warning<<"Insufficient number of filedescriptors available for max-mthreads*threads setting! ("<<availFDs<<" < "<<g_maxMThreads*g_numThreads<<"), reducing max-mthreads to "<<newval<<endl;
++      g_maxMThreads = newval;
++      setFilenumLimit(g_maxMThreads * g_numThreads);
++    }
++
++    
++  }
+ 
+   if(g_numThreads == 1) {
+     L<<Logger::Warning<<"Operating unthreaded"<<endl;
+-- 
+1.8.5.1
+
diff --git a/pdns-recursor.spec b/pdns-recursor.spec
index 6ecb8c6..1613c4f 100644
--- a/pdns-recursor.spec
+++ b/pdns-recursor.spec
@@ -1,6 +1,6 @@
 Name: pdns-recursor
 Version: 3.5.3
-Release: 1%{?dist}
+Release: 2%{?dist}
 Summary: Modern, advanced and high performance recursing/non authoritative name server
 Group: System Environment/Daemons
 License: GPLv2
@@ -9,6 +9,7 @@ Source0: http://downloads.powerdns.com/releases/%{name}-%{version}.tar.bz2
 Source1: pdns-recursor.init
 Patch0: pdns-recursor-fixsysconfdir.patch
 Patch1: pdns-recursor-fixmakefile.patch
+Patch2: pdns-recursor-fixmthreads.patch
 
 Provides: powerdns-recursor = %{version}-%{release}
 BuildRequires: boost-devel
@@ -27,6 +28,7 @@ package if you need a dns cache for your network.
 %setup -q
 %patch0 -p1 -b .fixsysconfdir
 %patch1 -p1 -b .fixmakefile
+%patch2 -p2 -b .fixmthreads
 
 %build
 LUA=1 LUA_CPPFLAGS_CONFIG= LUA_LIBS_CONFIG=-llua OPTFLAGS="%{optflags}" LDFLAGS="%{?__global_ldflags}" make %{?_smp_mflags}
@@ -80,6 +82,9 @@ fi
 %doc COPYING README
 
 %changelog
+* Mon Feb 10 2014 Morten Stevens <mstevens at imt-systems.com> - 3.5.3-2
+- Add upstream patch to fix rhbz#1063304
+
 * Tue Sep 17 2013 Morten Stevens <mstevens at imt-systems.com> - 3.5.3-1
 - Update to 3.5.3
 


More information about the scm-commits mailing list