dr.d_string=DNSRR2String(*i);
k=stored.find(dr);
if(k!=stored.end()) { // was it there already?
- // cerr<<"updating record '"<<qname<<"' -> '"<<i->content<<"'\n";
+ // cerr<<"updating record '"<<qname<<"' -> '"<<i->content<<"'\n";
k->d_ttd=i->ttl; // update ttl
touched.push_back(k); // note that this record is here to stay
}
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 '"<<qname<<"' '"<<rr.content<<"'\n";
- k->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 '"<<qname<<"' '"<<rr.content<<"'\n";
+ // k->d_string.prune();
+ stored.erase(k++); // cleanup
+ }
+ else
+ ++k;
}
- else
- ++k;
}
}
for(cache_t::iterator j=d_cache.begin();j!=d_cache.end();){
for(set<StoredRecord>::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++;
}
#include "dns.hh"
#include "qtype.hh"
#include <iostream>
+#include <boost/utility.hpp>
template<int N=14>
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) {
} __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<DNSResourceRecord>* res);
void replace(const string &qname, const QType& qt, const set<DNSResourceRecord>& content);
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;