}
}
catch (std::exception &e) {
- while (B.get(rr)) ; // don't leave DB handle in bad state
+ B.lookupEnd(); // don't leave DB handle in bad state
throw;
}
B.lookup(QType(QType::ANY), subdomain, d_sd.domain_id, &p);
if (B.get(rr)) {
DLOG(g_log<<"No wildcard match, ancestor exists"<<endl);
- while (B.get(rr)) ;
+ B.lookupEnd();
break;
}
wildcard=subdomain;
break;
}
default:
- while (B.get(rr)) ; // don't leave DB handle in bad state
+ B.lookupEnd(); // don't leave DB handle in bad state
throw PDNSException("Unknown type (" + QType(qtype).toString() + ") for additional service processing");
}
}
}
catch(std::exception &e) {
- while (B.get(rr)) ; // don't leave DB handle in bad state
+ B.lookupEnd(); // don't leave DB handle in bad state
r=p.replyPacket();
r->setRcode(RCode::ServFail);
return false;
}
+void UeberBackend::lookupEnd()
+{
+ if (!d_negcached && !d_cached) {
+ DNSZoneRecord zoneRecord;
+ while (d_handle.get(zoneRecord)) {
+ // Read all answers so the backends will close any database handles they might have allocated.
+ // One day this could be optimized.
+ }
+ }
+
+ d_answers.clear();
+ d_cached = d_negcached = false;
+}
+
// TSIG
//
bool UeberBackend::setTSIGKey(const DNSName& name, const DNSName& algorithm, const string& content)
};
void lookup(const QType& qtype, const DNSName& qname, int zoneId, DNSPacket* pkt_p = nullptr);
+ /** Read a single record from a lookup(...) result. */
+ bool get(DNSZoneRecord& resourceRecord);
+ /** Close state created by lookup(...). */
+ void lookupEnd();
/** Determines if we are authoritative for a zone, and at what level */
bool getAuth(const DNSName& target, const QType& qtype, SOAData* soaData, bool cachedOk = true);
/** Load SOA info from backends, ignoring the cache.*/
bool getSOAUncached(const DNSName& domain, SOAData& soaData);
- bool get(DNSZoneRecord& resourceRecord);
void getAllDomains(vector<DomainInfo>* domains, bool getSerial, bool include_disabled);
void getUnfreshSecondaryInfos(vector<DomainInfo>* domains);