return true;
}
+// This is a naive implementation which invokes get() until there are no more
+// records available and the backend closes any database handle it might have
+// allocated. Backends which can do better shall override this with smarter
+// code.
+void DNSBackend::lookupEnd()
+{
+ DNSZoneRecord zoneRecord;
+ while (get(zoneRecord)) {
+ // do nothing
+ }
+}
+
bool DNSBackend::getBeforeAndAfterNames(domainid_t domainId, const ZoneName& zonename, const DNSName& qname, DNSName& before, DNSName& after)
{
DNSName unhashed;
virtual void APILookup(const QType& qtype, const DNSName& qdomain, domainid_t zoneId, bool include_disabled = false);
virtual bool get(DNSResourceRecord&) = 0; //!< retrieves one DNSResource record, returns false if no more were available
virtual bool get(DNSZoneRecord& zoneRecord);
+ //! Close state created by lookup(...).
+ virtual void lookupEnd();
//! Initiates a list of the specified domain
/** Once initiated, DNSResourceRecord objects can be retrieved using get(). Should 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_handle.lookupEnd();
}
d_answers.clear();
i = parent->backends.size(); // don't go on to the next backend
return true;
}
+
+void UeberBackend::handle::lookupEnd() const
+{
+ if (d_hinterBackend != nullptr) {
+ d_hinterBackend->lookupEnd();
+ }
+}
{
public:
bool get(DNSZoneRecord& record);
+ void lookupEnd() const;
handle();
~handle();