]> granicus.if.org Git - pdns/commitdiff
fill in notified_serial and serial in gsql getDomainInfo
authorChristian Hofstaedtler <christian@hofstaedtler.name>
Wed, 21 Aug 2013 16:12:31 +0000 (18:12 +0200)
committerChristian Hofstaedtler <christian@hofstaedtler.name>
Wed, 21 Aug 2013 18:29:02 +0000 (20:29 +0200)
Filling in notified_serial is free; the query already fetches
notified_serial, but we didn't copy it over.
We now also always try the SOA lookup to get the domain serial, which
previously only happened in the SLAVE case. This might provoke a few
more notices/errors, but not really for sane database contents.

pdns/backends/gsql/gsqlbackend.cc

index 0dc190d36427691233258eba7f1af321a2328cc3..57c0f071f2368aed152de45a8987bd17b91430a0 100644 (file)
@@ -107,8 +107,8 @@ bool GSQLBackend::isMaster(const string &domain, const string &ip)
 
 bool GSQLBackend::getDomainInfo(const string &domain, DomainInfo &di)
 {
-  /* list all domains that need refreshing for which we are slave, and insert into SlaveDomain:
-     id,name,master IP,serial */
+  /* fill DomainInfo from database info:
+     id,name,master IP(s),last_check,notified_serial,type */
   char output[1024];
   snprintf(output,sizeof(output)-1,d_InfoOfDomainsZoneQuery.c_str(),
           sqlEscape(domain).c_str());
@@ -127,29 +127,29 @@ bool GSQLBackend::getDomainInfo(const string &domain, DomainInfo &di)
   di.zone=d_result[0][1];
   stringtok(di.masters, d_result[0][2], " ,\t");
   di.last_check=atol(d_result[0][3].c_str());
+  di.notified_serial = atol(d_result[0][4].c_str());
   di.backend=this;
-  
+
+  di.serial = 0;
+  try {
+    SOAData sd;
+    if(!getSOA(domain,sd))
+      L<<Logger::Notice<<"No serial for '"<<domain<<"' found - zone is missing?"<<endl;
+    else
+      di.serial = sd.serial;
+  }
+  catch(PDNSException &ae){
+    L<<Logger::Error<<"Error retrieving serial for '"<<domain<<"': "<<ae.reason<<endl;
+  }
+
   string type=d_result[0][5];
-  if(pdns_iequals(type,"SLAVE")) {
-    di.serial=0;
-    try {
-      SOAData sd;
-      if(!getSOA(domain,sd)) 
-        L<<Logger::Notice<<"No serial for '"<<domain<<"' found - zone is missing?"<<endl;
-      else
-        di.serial=sd.serial;
-    }
-    catch(PDNSException &ae){
-      L<<Logger::Error<<"Error retrieving serial for '"<<domain<<"': "<<ae.reason<<endl;
-    }
-    
+  if(pdns_iequals(type,"SLAVE"))
     di.kind=DomainInfo::Slave;
-  }
   else if(pdns_iequals(type,"MASTER"))
     di.kind=DomainInfo::Master;
   else 
     di.kind=DomainInfo::Native;
-  
+
   return true;
 }