]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
move some functions around, plus when reloading a zone because it changed, hand out...
authorBert Hubert <bert.hubert@netherlabs.nl>
Tue, 30 Oct 2012 13:36:47 +0000 (13:36 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Tue, 30 Oct 2012 13:36:47 +0000 (13:36 +0000)
'realtime reloading' caused crashes. The resulting 'servfail' does appear to be cached slightly, so we need to work on that too.
This makes it appear that a domain vanished for a little bit.

git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2837 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/backends/bind/bindbackend2.cc
pdns/backends/bind/bindbackend2.hh

index ca538e7769c0e210e3abd5595399aaa83a94b812..c9369ae35e8b60d14b9ff4cc582bfe3896e282e7 100644 (file)
@@ -1,6 +1,6 @@
 /*
     PowerDNS Versatile Database Driven Nameserver
-    Copyright (C) 2002 - 2011  PowerDNS.COM BV
+    Copyright (C) 2002 - 2012  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 as 
@@ -464,12 +464,6 @@ void Bind2Backend::insert(shared_ptr<State> stage, int id, const string &qnameu,
   records.insert(bdr);
 }
 
-void Bind2Backend::reload()
-{
-  Lock l(&s_state_lock);
-  for(id_zone_map_t::iterator i = s_state->id_zone_map.begin(); i != s_state->id_zone_map.end(); ++i) 
-    i->second.d_checknow=true;
-}
 
 string Bind2Backend::DLReloadNowHandler(const vector<string>&parts, Utility::pid_t ppid)
 {
@@ -559,27 +553,19 @@ Bind2Backend::Bind2Backend(const string &suffix, bool loadZones)
 
 Bind2Backend::~Bind2Backend()
 {
-
 }
 
 void Bind2Backend::rediscover(string *status)
 {
   loadConfig(status);
 }
-#if 0
-static void prefetchFile(const std::string& fname)
-{
-
-  static int fd;
-  if(fd > 0)
-    close(fd);
-  fd=open(fname.c_str(), O_RDONLY);
-  if(fd < 0)
-    return;
 
-  posix_fadvise(fd, 0, 0, POSIX_FADV_WILLNEED);
+void Bind2Backend::reload()
+{
+  Lock l(&s_state_lock);
+  for(id_zone_map_t::iterator i = s_state->id_zone_map.begin(); i != s_state->id_zone_map.end(); ++i) 
+    i->second.d_checknow=true;
 }
-#endif 
 
 void Bind2Backend::fixupAuth(shared_ptr<recordstorage_t> records)
 {
@@ -870,9 +856,10 @@ void Bind2Backend::queueReload(BB2DomainInfo *bbd)
   // we reload *now* for the time being
 
   try {
-    nukeZoneRecords(bbd); // ? do we need this?
+    // nukeZoneRecords(bbd); // ? do we need this?
     staging->id_zone_map[bbd->d_id]=s_state->id_zone_map[bbd->d_id];
-    staging->id_zone_map[bbd->d_id].d_records=shared_ptr<recordstorage_t > (new recordstorage_t);  // nuke it
+    shared_ptr<recordstorage_t > newrecords(new recordstorage_t);
+    staging->id_zone_map[bbd->d_id].d_records=newrecords;
 
     ZoneParserTNG zpt(bbd->d_filename, bbd->d_name, s_binddirectory);
     DNSResourceRecord rr;
@@ -1085,7 +1072,7 @@ void Bind2Backend::lookup(const QType &qtype, const string &qname, DNSPacket *pk
   if(!bbd.current()) {
     L<<Logger::Warning<<"Zone '"<<bbd.d_name<<"' ("<<bbd.d_filename<<") needs reloading"<<endl;
     queueReload(&bbd);  // how can this be safe - ok, everybody should have their own reference counted copy of 'records'
-    state = s_state;
+    throw DBException("Zone for '"+bbd.d_name+"' in '"+bbd.d_filename+"' being reloaded"); // if we don't throw here, we crash for some reason
   }
 
   d_handle.d_records = bbd.d_records; // give it a reference counted copy
@@ -1151,6 +1138,13 @@ bool Bind2Backend::handle::get(DNSResourceRecord &r)
     return get_normal(r);
 }
 
+void Bind2Backend::handle::reset()
+{
+  d_records.reset();
+  qname.clear();
+  mustlog=false;
+}
+
 //#define DLOG(x) x
 bool Bind2Backend::handle::get_normal(DNSResourceRecord &r)
 {
index a739caa6b480b711d7b6480db649dc88789f6d64..49e6db4155d8007cc2782aaa728d81a2c14b318c 100644 (file)
@@ -91,10 +91,10 @@ class BB2DomainInfo
 {
 public:
   BB2DomainInfo();
-
   void setCtime();
-
   bool current();
+  //! configure how often this domain should be checked for changes (on disk)
+  void setCheckInterval(time_t seconds);
 
   bool d_loaded;  //!< if a domain is loaded
   string d_status; //!< message describing status of a domain, for human consumption
@@ -109,13 +109,9 @@ public:
 
   uint32_t d_lastnotified; //!< Last serial number we notified our slaves of
 
-  //! configure how often this domain should be checked for changes (on disk)
-  void setCheckInterval(time_t seconds);
-
   shared_ptr<recordstorage_t > d_records;  //!< the actual records belonging to this domain
 private:
   time_t getCtime();
-
   time_t d_checkinterval;
 };
 
@@ -191,13 +187,8 @@ private:
   {
   public:
     bool get(DNSResourceRecord &);
-    void reset()
-    {
-      d_records.reset();
-      qname.clear();
-      mustlog=false;
-    }
-
+    void reset();
+    
     handle();
 
     shared_ptr<recordstorage_t > d_records;