]> granicus.if.org Git - pdns/commitdiff
speedup for pdns_recursor, fix crashes of BIND backend, fix filedescriptor leak in...
authorBert Hubert <bert.hubert@netherlabs.nl>
Mon, 26 Mar 2007 20:18:23 +0000 (20:18 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Mon, 26 Mar 2007 20:18:23 +0000 (20:18 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@999 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/Makefile-recursor
pdns/backends/bind/bindbackend2.cc
pdns/backends/bind/bindbackend2.hh
pdns/backends/bind/bindparser.hh

index 66aba1add0f96431e82f8481e7bb8690b8c997c4..879760c13c142eaf00a8c83f05e9cda311d61267 100644 (file)
@@ -3,7 +3,7 @@ SBINDIR=/usr/sbin/
 BINDIR=/usr/bin/
 CONFIGDIR="/etc/powerdns/"
 OPTFLAGS?=-O3
-CXXFLAGS:= $(CXXFLAGS) -Wall $(OPTFLAGS) $(PROFILEFLAGS)
+CXXFLAGS:= $(CXXFLAGS) -Wall -DBOOST_SP_DISABLE_THREADS $(OPTFLAGS) $(PROFILEFLAGS)
 CFLAGS:=$(CFLAGS) -Wall $(OPTFLAGS) $(PROFILEFLAGS)
 LINKCC=$(CXX)
 CC?=gcc
index 560947947fa8d40e1269cacd5c24f9e07c1f23e2..e952bfbc4a3c7cf15701be4221947b8784f8064a 100644 (file)
@@ -454,7 +454,6 @@ Bind2Backend::Bind2Backend(const string &suffix)
   if(!s_first) {
     return;
   }
-   
   s_first=0;
   s_state = shared_ptr<State>(new State);
   loadConfig();
@@ -466,6 +465,14 @@ Bind2Backend::Bind2Backend(const string &suffix)
   dl->registerFunc("BIND-LIST-REJECTS", &DLListRejectsHandler);
 }
 
+Bind2Backend::~Bind2Backend()
+{
+  if(us==this) {
+    L<<Logger::Error<<"Main bind2backend instance being destructed"<<endl;
+    exit(1);
+  }
+}
+
 void Bind2Backend::rediscover(string *status)
 {
   us->loadConfig(status);
@@ -629,8 +636,8 @@ void Bind2Backend::loadConfig(string* status)
     vector<string> diff2;
     set_difference(newnames.begin(), newnames.end(), oldnames.begin(), oldnames.end(), back_inserter(diff2));
     newdomains=diff2.size();
-
-    s_state = staging; // and boy do we hope this is a threadsafe operation!
+    
+    s_state.swap(staging); // and boy do we hope this is a threadsafe operation!
 
     // report
     ostringstream msg;
index 68acd0d1d3e568cac0a782b27c20708a9bc68dbf..2fc6c438128ba872f7463e2a34578e43ee4c2c15 100644 (file)
@@ -28,7 +28,6 @@
 using namespace std;
 using namespace boost;
 
-
 /** This struct is used within the Bind2Backend to store DNS information. 
     It is almost identical to a DNSResourceRecord, but then a bit smaller and with different sorting rules, which make sure that the SOA record comes up front.
 */
@@ -90,11 +89,11 @@ class Bind2Backend : public DNSBackend
 {
 public:
   Bind2Backend(const string &suffix=""); //!< Makes our connection to the database. Calls exit(1) if it fails.
+  ~Bind2Backend();
   void getUnfreshSlaveInfos(vector<DomainInfo> *unfreshDomains);
   void getUpdatedMasters(vector<DomainInfo> *changedDomains);
   bool getDomainInfo(const string &domain, DomainInfo &di);
   time_t getCtime(const string &fname);
-  
 
   void lookup(const QType &, const string &qdomain, DNSPacket *p=0, int zoneId=-1);
   bool list(const string &target, int id);
@@ -114,7 +113,7 @@ public:
   typedef map<string, int> name_id_map_t;
   typedef map<uint32_t, BB2DomainInfo> id_zone_map_t;
 
-  struct State 
+  struct State : public boost::noncopyable
   {
     name_id_map_t name_id_map;  //!< convert a name to a domain id
     id_zone_map_t id_zone_map;
index 8b130d09e5b8d4fa8f35a6b5e124fb1288e3ca19..5ec661a683c797562317812f686a8dc084544896 100644 (file)
@@ -38,16 +38,25 @@ public:
 };
 
 extern const char *bind_directory;
+extern FILE *yyin;
 class BindParser
 {
  public:
-  BindParser() : d_dir("."), d_verbose(false) 
+  BindParser() : d_dir("."), d_verbose(false)
   {
+    yyin=0;
     extern int include_stack_ptr;
     include_stack_ptr=0;
  
     bind_directory=d_dir.c_str(); 
   }
+  ~BindParser()
+  {
+    if(yyin) {
+      fclose(yyin);
+      yyin=0;
+    }
+  }
   void parse(const string &fname);
   void commit(BindDomainInfo DI);
   void setDirectory(const string &dir);