]> granicus.if.org Git - pdns/commitdiff
add multiple master support to gsqlbackends - forward port from 2.9.22.x
authorBert Hubert <bert.hubert@netherlabs.nl>
Mon, 10 Jan 2011 13:42:59 +0000 (13:42 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Mon, 10 Jan 2011 13:42:59 +0000 (13:42 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1857 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/backends/gsql/gsqlbackend.cc

index 54520c633c920892c48064d0daa1e49b35776646..b0c9d0435ae12f7f2c3d7d0a6c0a31a93bab8fe6 100644 (file)
@@ -67,8 +67,21 @@ bool GSQLBackend::isMaster(const string &domain, const string &ip)
 
   if(d_result.empty())
     return 0;
-  
-  return !strcmp(ip.c_str(),d_result[0][0].c_str());
+
+  // we can have multiple masters separated by commas
+  vector<string> masters;
+  stringtok(masters, d_result[0][0], " ,\t");
+  for(vector<string>::const_iterator iter=masters.begin(); iter != masters.end(); ++iter) {
+     // we can also have masters with a port specified (which we ignore here)
+     ServiceTuple st;
+     parseService(*iter, st);
+     if (!strcmp(ip.c_str(), st.host.c_str())) {
+         return 1;
+     }
+  }
+
+ // if no masters matched then this is not a master
+  return 0;  
 }
 
 bool GSQLBackend::getDomainInfo(const string &domain, DomainInfo &di)