Index: pdns/dnsbackend.hh =================================================================== --- pdns/dnsbackend.hh (revision 2265) +++ pdns/dnsbackend.hh (working copy) @@ -50,6 +50,8 @@ uint32_t notified_serial; uint32_t serial; time_t last_check; + uint32_t refresh; + uint32_t retry; enum {Master,Slave,Native} kind; DNSBackend *backend; @@ -187,7 +189,7 @@ } //! Called by PowerDNS to inform a backend that a domain has been checked for freshness - virtual void setFresh(uint32_t domain_id) + virtual void setFresh(uint32_t domain_id, uint32_t refresh) { } Index: pdns/slavecommunicator.cc =================================================================== --- pdns/slavecommunicator.cc (revision 2266) +++ pdns/slavecommunicator.cc (working copy) @@ -70,7 +70,8 @@ void CommunicatorClass::suck(const string &domain,const string &remote) { L< nsset, qnames; @@ -155,6 +157,11 @@ nsset.insert(i->qname); if(i->qtype.getCode() != QType::RRSIG) // this excludes us hashing RRSIGs for NSEC(3) qnames.insert(i->qname); + if(i->qtype.getCode() == QType::SOA) { + SOAData sdata; + fillSOAData(i->content, sdata); + di.refresh=sdata.refresh; + } i->domain_id=domain_id; #if 0 @@ -200,7 +207,7 @@ } di.backend->commitTransaction(); - di.backend->setFresh(domain_id); + di.backend->setFresh(domain_id,di.refresh); L<abortTransaction(); } + if(domain_id_isvalid) + di.backend->setFresh(domain_id,di.retry); } catch(MOADNSException &re) { L<abortTransaction(); } + if(domain_id_isvalid) + di.backend->setFresh(domain_id,di.retry); } catch(std::exception &re) { L<abortTransaction(); } + if(domain_id_isvalid) + di.backend->setFresh(domain_id,di.retry); } catch(ResolverException &re) { L<abortTransaction(); } + if(domain_id_isvalid) + di.backend->setFresh(domain_id,di.retry); } } namespace { @@ -402,12 +417,12 @@ if(rfc1982LessThan(theirserial, ourserial)) { L< their serial "<< theirserial << endl; - di.backend->setFresh(di.id); + di.backend->setFresh(di.id,di.refresh); } else if(theirserial == ourserial) { if(!dk.isPresigned(di.zone)) { L<setFresh(di.id); + di.backend->setFresh(di.id,di.refresh); } else { B->lookup(QType(QType::RRSIG), di.zone); // can't use DK before we are done with this lookup! @@ -422,7 +437,7 @@ } if(maxInception == ssr.d_freshness[di.id].theirInception && maxExpire == ssr.d_freshness[di.id].theirExpire) { L<setFresh(di.id); + di.backend->setFresh(di.id, di.refresh); } else { L<push_back(sd); } - - for(vector::iterator i=allSlaves.begin();i!=allSlaves.end();++i) { - SOAData sdata; - sdata.serial=0; - sdata.refresh=0; - getSOA(i->zone,sdata); - if((time_t)(i->last_check+sdata.refresh) < time(0)) { - i->serial=sdata.serial; - unfreshDomains->push_back(*i); - } - } } void GSQLBackend::getUpdatedMasters(vector *updatedDomains) Index: pdns/backends/gsql/gsqlbackend.hh =================================================================== --- pdns/backends/gsql/gsqlbackend.hh (revision 2265) +++ pdns/backends/gsql/gsqlbackend.hh (working copy) @@ -33,7 +33,7 @@ bool feedRecord(const DNSResourceRecord &r); bool createSlaveDomain(const string &ip, const string &domain, const string &account); bool superMasterBackend(const string &ip, const string &domain, const vector&nsset, string *account, DNSBackend **db); - void setFresh(uint32_t domain_id); + void setFresh(uint32_t domain_id, uint32_t refresh); bool checkACL(const string &acl_type, const string &key, const string &value); void getUnfreshSlaveInfos(vector *domains); void getUpdatedMasters(vector *updatedDomains); Index: pdns/backends/bind/bindbackend2.hh =================================================================== --- pdns/backends/bind/bindbackend2.hh (revision 2265) +++ pdns/backends/bind/bindbackend2.hh (working copy) @@ -135,7 +135,7 @@ static DNSBackend *maker(); static pthread_mutex_t s_startup_lock; - void setFresh(uint32_t domain_id); + void setFresh(uint32_t domain_id, uint32_t refresh); void setNotified(uint32_t id, uint32_t serial); bool startTransaction(const string &qname, int id); // bool Bind2Backend::stopTransaction(const string &qname, int id); Index: pdns/backends/bind/bindbackend2.cc =================================================================== --- pdns/backends/bind/bindbackend2.cc (revision 2265) +++ pdns/backends/bind/bindbackend2.cc (working copy) @@ -137,7 +137,7 @@ s_state->id_zone_map[id].d_lastnotified=serial; } -void Bind2Backend::setFresh(uint32_t domain_id) +void Bind2Backend::setFresh(uint32_t domain_id, uint32_t refresh) { Lock l(&s_state_lock); s_state->id_zone_map[domain_id].d_lastcheck=time(0); @@ -335,12 +335,16 @@ di.backend=this; di.kind=i->second.d_masters.empty() ? DomainInfo::Master : DomainInfo::Slave; di.serial=0; + di.refresh=0; + di.retry=0; try { SOAData sd; sd.serial=0; getSOA(i->second.d_name,sd); // we might not *have* a SOA yet di.serial=sd.serial; + di.refresh=sd.refresh; + di.retry=sd.retry; } catch(...){} Index: modules/gpgsqlbackend/gpgsqlbackend.cc =================================================================== --- modules/gpgsqlbackend/gpgsqlbackend.cc (revision 2265) +++ modules/gpgsqlbackend/gpgsqlbackend.cc (working copy) @@ -78,7 +78,7 @@ declare(suffix,"info-zone-query","","select id,name,master,last_check,notified_serial,type from domains where name=E'%s'"); - declare(suffix,"info-all-slaves-query","","select id,name,master,last_check,type from domains where type='SLAVE'"); + declare(suffix,"info-all-slaves-query","","select id,name,master,last_check,type from domains where type='SLAVE' and next_check < extract(epoch from now())::integer"); declare(suffix,"supermaster-query","", "select account from supermasters where ip='%s' and nameserver=E'%s'"); declare(suffix,"insert-slave-query","", "insert into domains (type,name,master,account) values('SLAVE',E'%s',E'%s',E'%s')"); declare(suffix,"insert-record-query","", "insert into records (content,ttl,prio,type,domain_id,name) values (E'%s',%d,%d,'%s',%d,E'%s')"); @@ -90,7 +90,7 @@ declare(suffix,"update-serial-query","", "update domains set notified_serial=%d where id=%d"); - declare(suffix,"update-lastcheck-query","", "update domains set last_check=%d where id=%d"); + declare(suffix,"update-lastcheck-query","", "update domains set last_check=%d,next_check=%d where id=%d"); declare(suffix,"info-all-master-query","", "select id,name,master,last_check,notified_serial,type from domains where type='MASTER'"); declare(suffix,"delete-zone-query","", "delete from records where domain_id=%d"); declare(suffix,"check-acl-query","", "select value from acls where acl_type='%s' and acl_key='%s'");