From: Bert Hubert Date: Wed, 2 Nov 2005 15:22:59 +0000 (+0000) Subject: back out optString for now X-Git-Tag: pdns-2.9.20~52 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8e8432823f082791f146759d2703423fa2212caa;p=pdns back out optString for now special-special case MemRecursorCache::replace for the even more common case where nothing changed except the ttls git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@536 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/recursor_cache.cc b/pdns/recursor_cache.cc index f176051d3..c036a682c 100644 --- a/pdns/recursor_cache.cc +++ b/pdns/recursor_cache.cc @@ -77,7 +77,7 @@ void MemRecursorCache::replace(const string &qname, const QType& qt, const set< dr.d_string=DNSRR2String(*i); k=stored.find(dr); if(k!=stored.end()) { // was it there already? - // cerr<<"updating record '"< '"<content<<"'\n"; + // cerr<<"updating record '"< '"<content<<"'\n"; k->d_ttd=i->ttl; // update ttl touched.push_back(k); // note that this record is here to stay } @@ -86,18 +86,19 @@ void MemRecursorCache::replace(const string &qname, const QType& qt, const set< touched.push_back(stored.insert(dr).first); // same thing } } - - for(k=stored.begin(); k!=stored.end(); ) { // walk over the stored set of records - touched_t::const_iterator j; - for(j=touched.begin(); j!=touched.end() && *j != k ; ++j); // walk over touched iterators - if(j==touched.end()) { // this record was not there - // DNSResourceRecord rr=String2DNSRR(qname, qt, k->d_string, 0); - // cerr<<"removing from record '"<d_string.prune(); - stored.erase(k++); // cleanup + if(touched.size() != stored.size()) { + for(k=stored.begin(); k!=stored.end(); ) { // walk over the stored set of records + touched_t::const_iterator j; + for(j=touched.begin(); j!=touched.end() && *j != k ; ++j); // walk over touched iterators + if(j==touched.end()) { // this record was not there + // DNSResourceRecord rr=String2DNSRR(qname, qt, k->d_string, 0); + // cerr<<"removing from record '"<d_string.prune(); + stored.erase(k++); // cleanup + } + else + ++k; } - else - ++k; } } @@ -108,7 +109,7 @@ void MemRecursorCache::doPrune(void) for(cache_t::iterator j=d_cache.begin();j!=d_cache.end();){ for(set::iterator k=j->second.begin();k!=j->second.end();) if((unsigned int)k->d_ttd < (unsigned int) now) { - k->d_string.prune(); + // k->d_string.prune(); j->second.erase(k++); records++; } diff --git a/pdns/recursor_cache.hh b/pdns/recursor_cache.hh index 9ad8385ed..5cb8070fd 100644 --- a/pdns/recursor_cache.hh +++ b/pdns/recursor_cache.hh @@ -6,6 +6,7 @@ #include "dns.hh" #include "qtype.hh" #include +#include template struct optString @@ -16,6 +17,11 @@ struct optString *buf=0; } + optString(const optString& rhs) : d_len(rhs.d_len) + { + memcpy(buf, rhs.buf, N); + } + optString(const string& str) { if(str.size() < N-1) { @@ -56,12 +62,9 @@ struct optString } __attribute__((packed)); - - -class MemRecursorCache // : public RecursorCache +class MemRecursorCache : public boost::noncopyable // : public RecursorCache { public: - ~MemRecursorCache(){} unsigned int size(); int get(time_t, const string &qname, const QType& qt, set* res); void replace(const string &qname, const QType& qt, const set& content); @@ -72,7 +75,8 @@ private: struct StoredRecord { mutable uint32_t d_ttd; - optString<> d_string; + // optString<> d_string; + string d_string; bool operator<(const StoredRecord& rhs) const { return d_string < rhs.d_string;