]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Merge pull request #1027 from paboldin/bind-lock-file
authorPeter van Dijk <peter@7bits.nl>
Tue, 22 Oct 2013 09:06:57 +0000 (02:06 -0700)
committerPeter van Dijk <peter@7bits.nl>
Tue, 22 Oct 2013 09:06:57 +0000 (02:06 -0700)
bind-supermaster-lock: use different lock for supermaster config file

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

index c6fa1c112ba544d7472bb46e401bae8ab1281295,ef0bb9cc19aed1955ccc28c39d9271f576343e69..919e6f682eaf1c49802563361dbd6f1cc0b33de3
@@@ -1344,23 -1343,30 +1343,30 @@@ bool Bind2Backend::createSlaveDomain(co
    L << Logger::Warning << d_logprefix
      << " Writing bind config zone statement for superslave zone '" << domain
      << "' from supermaster " << ip << endl;
+   {
+     Lock l2(&s_supermaster_config_lock);
          
-   ofstream c_of(getArg("supermaster-config").c_str(),  std::ios::app);
-   if (!c_of) {
-     L << Logger::Error << "Unable to open supermaster configfile for append: " << stringerror() << endl;
-     throw DBException("Unable to open supermaster configfile for append: "+stringerror());
+     ofstream c_of(getArg("supermaster-config").c_str(),  std::ios::app);
+     if (!c_of) {
+       L << Logger::Error << "Unable to open supermaster configfile for append: " << stringerror() << endl;
+       throw DBException("Unable to open supermaster configfile for append: "+stringerror());
+     }
+     
+     c_of << endl;
+     c_of << "# Superslave zone " << domain << " (added: " << nowTime() << ") (account: " << account << ')' << endl;
+     c_of << "zone \"" << domain << "\" {" << endl;
+     c_of << "\ttype slave;" << endl;
+     c_of << "\tfile \"" << filename << "\";" << endl;
+     c_of << "\tmasters { " << ip << "; };" << endl;
+     c_of << "};" << endl;
+     c_of.close();
    }
-   
-   c_of << endl;
-   c_of << "# Superslave zone " << domain << " (added: " << nowTime() << ") (account: " << account << ')' << endl;
-   c_of << "zone \"" << domain << "\" {" << endl;
-   c_of << "\ttype slave;" << endl;
-   c_of << "\tfile \"" << filename << "\";" << endl;
-   c_of << "\tmasters { " << ip << "; };" << endl;
-   c_of << "};" << endl;
-   c_of.close();
+   // Interference with loadConfig() and DLAddDomainHandler(), use locking
+   Lock l(&s_state_lock);
  
 -  BB2DomainInfo &bbd = createDomain(canonic(domain), filename);
 +  BB2DomainInfo &bbd = createDomainEntry(canonic(domain), filename);
  
    bbd.d_masters.push_back(ip);
    
Simple merge