From d381d4a467e05755559557c0704cc581eed78853 Mon Sep 17 00:00:00 2001 From: Ori Markovitch Date: Tue, 23 May 2017 07:42:41 -0700 Subject: [PATCH] See #3602, made requests always return to sender, for usage in multi master slave zones. Also - made sure that the master that is questioned for updates will be selected randomly, to prevent repeatidally asking a dead master for updates (cherry picked from commit 86e9686baad04d9f21af1a18180ef6cd2f483086) --- pdns/slavecommunicator.cc | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/pdns/slavecommunicator.cc b/pdns/slavecommunicator.cc index 4b6da4dbf..f065bba08 100644 --- a/pdns/slavecommunicator.cc +++ b/pdns/slavecommunicator.cc @@ -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<