]> granicus.if.org Git - pdns/commitdiff
See #3602, made requests always return to sender, for usage in multi master slave...
authorOri Markovitch <ori@redislabs.com>
Tue, 23 May 2017 14:42:41 +0000 (07:42 -0700)
committerOri Markovitch <ori@redislabs.com>
Sun, 26 Nov 2017 08:26:30 +0000 (00:26 -0800)
(cherry picked from commit 86e9686baad04d9f21af1a18180ef6cd2f483086)

pdns/slavecommunicator.cc

index 4b6da4dbfdd1dc0901624da36fa629e899ee2707..f065bba08f48f582dc2bdaf61b0db75258cf0986 100644 (file)
@@ -710,6 +710,19 @@ void CommunicatorClass::addSlaveCheckRequest(const DomainInfo& di, const ComboAd
   Lock l(&d_lock);
   DomainInfo ours = di;
   ours.backend = 0;
+  string remote_address = remote.toString();
+
+  // When adding a check, if the remote addr from which notification was
+  // received is a master, clear all other masters so we can be sure the
+  // query goes to that one.
+  for (const auto& master : ours.masters) {
+    if (master == remote_address) {
+      ours.masters.clear();
+      ours.masters.push_back(remote_address);
+      break;
+    }
+  }
+  d_tocheck.erase(di);
   d_tocheck.insert(ours);
   d_any_sem.post(); // kick the loop!
 }
@@ -856,10 +869,17 @@ void CommunicatorClass::slaveRefresh(PacketHandler *P)
   time_t now = time(0);
   for(val_t& val :  sdomains) {
     DomainInfo& di(val.di);
+    DomainInfo tempdi;
     // might've come from the packethandler
-    if(!di.backend && !B->getDomainInfo(di.zone, di)) {
+    // Please do not overwrite received DI just to make sure it exists in backend.
+    if(!di.backend) {
+      if (!B->getDomainInfo(di.zone, tempdi)) {
         L<<Logger::Warning<<"Ignore domain "<< di.zone<<" since it has been removed from our backend"<<endl;
         continue;
+      }
+      // Backend for di still doesn't exist and this might cause us to
+      // SEGFAULT on the setFresh command later on
+      di.backend = tempdi.backend;
     }
 
     if(!ssr.d_freshness.count(di.id)) { // If we don't have an answer for the domain