]> granicus.if.org Git - pdns/commitdiff
moved some stuff around, added some comments
authorbert hubert <bert.hubert@netherlabs.nl>
Thu, 13 Mar 2014 07:48:22 +0000 (08:48 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Thu, 13 Mar 2014 07:48:22 +0000 (08:48 +0100)
modules/bindbackend/bindbackend2.cc
modules/bindbackend/bindbackend2.hh

index 67a6e453d27a8d524c8cc9e38619dd5bedc8cf14..a92ae5b58abdd82df910455fdb0a097f919fe0a5 100644 (file)
@@ -22,7 +22,6 @@
 
 #include <errno.h>
 #include <string>
-#include <map>
 #include <set>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -30,7 +29,6 @@
 #include <fstream>
 #include <fcntl.h>
 #include <sstream>
-#include <boost/bind.hpp>
 #include <boost/algorithm/string.hpp>
 #include <boost/foreach.hpp>
 #include "pdns/dnsseckeeper.hh"
@@ -110,6 +108,35 @@ void BB2DomainInfo::setCtime()
   d_ctime=buf.st_ctime;
 }
 
+bool Bind2Backend::safeGetBBDomainInfo(int id, BB2DomainInfo* bbd)
+{
+  ReadLock rl(&s_state_lock);
+  state_t::const_iterator iter = s_state.find(id);
+  if(iter == s_state.end())
+    return false;
+  *bbd=*iter;
+  return true;
+}
+
+bool Bind2Backend::safeGetBBDomainInfo(const std::string& name, BB2DomainInfo* bbd)
+{
+  ReadLock rl(&s_state_lock);
+  typedef state_t::index<NameTag>::type nameindex_t;
+  nameindex_t& nameindex = boost::multi_index::get<NameTag>(s_state);
+
+  nameindex_t::const_iterator iter = nameindex.find(name);
+  if(iter == nameindex.end())
+    return false;
+  *bbd=*iter;
+  return true;
+}
+
+void Bind2Backend::safePutBBDomainInfo(const BB2DomainInfo& bbd)
+{
+  WriteLock rl(&s_state_lock);
+  replacing_insert(s_state, bbd);
+}
+
 void Bind2Backend::setNotified(uint32_t id, uint32_t serial)
 {
   BB2DomainInfo bbd;
@@ -158,35 +185,6 @@ bool Bind2Backend::startTransaction(const string &qname, int id)
   return false;
 }
 
-bool Bind2Backend::safeGetBBDomainInfo(int id, BB2DomainInfo* bbd)
-{
-  ReadLock rl(&s_state_lock);
-  state_t::const_iterator iter = s_state.find(id);
-  if(iter == s_state.end())
-    return false;
-  *bbd=*iter;
-  return true;
-}
-
-bool Bind2Backend::safeGetBBDomainInfo(const std::string& name, BB2DomainInfo* bbd)
-{
-  ReadLock rl(&s_state_lock);
-  typedef state_t::index<NameTag>::type nameindex_t;
-  nameindex_t& nameindex = boost::multi_index::get<NameTag>(s_state);
-
-  nameindex_t::const_iterator iter = nameindex.find(name);
-  if(iter == nameindex.end())
-    return false;
-  *bbd=*iter;
-  return true;
-}
-
-void Bind2Backend::safePutBBDomainInfo(const BB2DomainInfo& bbd)
-{
-  WriteLock rl(&s_state_lock);
-  replacing_insert(s_state, bbd);
-}
-
 bool Bind2Backend::commitTransaction()
 {
   if(d_transaction_id < 0)
@@ -370,11 +368,11 @@ bool Bind2Backend::getDomainInfo(const string &domain, DomainInfo &di)
 
 void Bind2Backend::alsoNotifies(const string &domain, set<string> *ips)
 {
-  ReadLock rl(&s_state_lock);
   // combine global list with local list
   for(set<string>::iterator i = this->alsoNotify.begin(); i != this->alsoNotify.end(); i++) {
     (*ips).insert(*i);
   }
+  ReadLock rl(&s_state_lock);  
   for(state_t::const_iterator i = s_state.begin(); i != s_state.end() ; ++i) {
     if(pdns_iequals(i->d_name,domain)) {
       for(set<string>::iterator it = i->d_also_notify.begin(); it != i->d_also_notify.end(); it++) {
@@ -385,7 +383,8 @@ void Bind2Backend::alsoNotifies(const string &domain, set<string> *ips)
   }   
 }
 
-void Bind2Backend::parseZoneFile(BB2DomainInfo *bbd)
+// only parses, does NOT add to s_state!
+void Bind2Backend::parseZoneFile(BB2DomainInfo *bbd) 
 {
   NSEC3PARAMRecordContent ns3pr;
   bool nsec3zone=getNSEC3PARAM(bbd->d_name, &ns3pr);
@@ -405,7 +404,7 @@ void Bind2Backend::parseZoneFile(BB2DomainInfo *bbd)
       else
         hashed="";
     }
-    insert(*bbd, rr.qname, rr.qtype, rr.content, rr.ttl, rr.priority, hashed);
+    insertRecord(*bbd, rr.qname, rr.qtype, rr.content, rr.ttl, rr.priority, hashed);
   }
 
   fixupAuth(bbd->d_records.getWRITABLE());
@@ -419,7 +418,7 @@ void Bind2Backend::parseZoneFile(BB2DomainInfo *bbd)
 
 /** THIS IS AN INTERNAL FUNCTION! It does moadnsparser prio impedance matching
     Much of the complication is due to the efforts to benefit from std::string reference counting copy on write semantics */
-void Bind2Backend::insert(BB2DomainInfo& bb2, const string &qnameu, const QType &qtype, const string &content, int ttl, int prio, const std::string& hashed, bool *auth)
+void Bind2Backend::insertRecord(BB2DomainInfo& bb2, const string &qnameu, const QType &qtype, const string &content, int ttl, int prio, const std::string& hashed, bool *auth)
 {
   Bind2DNSRecord bdr;
   shared_ptr<recordstorage_t> records = bb2.d_records.getWRITABLE();
@@ -522,12 +521,11 @@ string Bind2Backend::DLDomStatusHandler(const vector<string>&parts, Utility::pid
 
 string Bind2Backend::DLListRejectsHandler(const vector<string>&parts, Utility::pid_t ppid)
 {
-  ReadLock rl(&s_state_lock);
   ostringstream ret;
+  ReadLock rl(&s_state_lock);
   for(state_t::const_iterator i = s_state.begin(); i != s_state.end() ; ++i) {
     if(!i->d_loaded)
       ret<<i->d_name<<"\t"<<i->d_status<<endl;
-        
   }
   return ret.str();
 }
@@ -682,7 +680,7 @@ void Bind2Backend::doEmptyNonTerminals(BB2DomainInfo& bbd, bool nsec3zone, NSEC3
     rr.qname=nt.first+"."+bbd.d_name+".";
     if(nsec3zone)
       hashed=toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, rr.qname));
-    insert(bbd, rr.qname, rr.qtype, rr.content, rr.ttl, rr.priority, hashed, &nt.second);
+    insertRecord(bbd, rr.qname, rr.qtype, rr.content, rr.ttl, rr.priority, hashed, &nt.second);
   }
 }
 
@@ -814,7 +812,6 @@ void Bind2Backend::queueReloadAndStore(unsigned int id)
 {
   BB2DomainInfo bbold;
   try {
-
     if(!safeGetBBDomainInfo(id, &bbold))
       return;
     parseZoneFile(&bbold);
index 49ea5685fd15ddea5eaa19a66b95e6c665756550..c5cfc31e0e4db3171369626ec8b0ea0a2d043b9e 100644 (file)
@@ -184,7 +184,7 @@ public:
   void getUpdatedMasters(vector<DomainInfo> *changedDomains);
   bool getDomainInfo(const string &domain, DomainInfo &di);
   time_t getCtime(const string &fname);
-  // DNSSEC
+   // DNSSEC
   virtual bool getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& qname, std::string& unhashed, std::string& before, std::string& after);
   void lookup(const QType &, const string &qdomain, DNSPacket *p=0, int zoneId=-1);
   bool list(const string &target, int id, bool include_disabled=false);
@@ -197,7 +197,6 @@ public:
   void setFresh(uint32_t domain_id);
   void setNotified(uint32_t id, uint32_t serial);
   bool startTransaction(const string &qname, int id);
-  //  bool Bind2Backend::stopTransaction(const string &qname, int id);
   bool feedRecord(const DNSResourceRecord &r, string *ordername=0);
   bool commitTransaction();
   bool abortTransaction();
@@ -228,7 +227,7 @@ public:
   static pthread_rwlock_t s_state_lock;
 
   void parseZoneFile(BB2DomainInfo *bbd);
-  static void insert(BB2DomainInfo& bbd, const string &qname, const QType &qtype, const string &content, int ttl=300, int prio=25, const std::string& hashed=string(), bool *auth=0);
+  void insertRecord(BB2DomainInfo& bbd, const string &qname, const QType &qtype, const string &content, int ttl=300, int prio=25, const std::string& hashed=string(), bool *auth=0);
   void rediscover(string *status=0);
 
   bool isMaster(const string &name, const string &ip);
@@ -299,7 +298,7 @@ private:
   static string DLReloadNowHandler(const vector<string>&parts, Utility::pid_t ppid);
   static string DLAddDomainHandler(const vector<string>&parts, Utility::pid_t ppid);
   static void fixupAuth(shared_ptr<recordstorage_t> records);
-  static void doEmptyNonTerminals(BB2DomainInfo& bbd, bool nsec3zone, NSEC3PARAMRecordContent ns3pr);
+  void doEmptyNonTerminals(BB2DomainInfo& bbd, bool nsec3zone, NSEC3PARAMRecordContent ns3pr);
   void loadConfig(string *status=0);
   static void nukeZoneRecords(BB2DomainInfo *bbd);
 };