qctx_freedata(qctx);
if (dns_view_staleanswerenabled(qctx->client->view)) {
- dns_db_attach(qctx->client->view->cachedb, &qctx->db);
- qctx->version = NULL;
+ isc_result_t ret;
+ ret = query_getdb(qctx->client, qctx->client->query.qname,
+ qctx->client->query.qtype, qctx->options,
+ &qctx->zone, &qctx->db, &qctx->version,
+ &qctx->is_zone);
+ if (ret != ISC_R_SUCCESS) {
+ /*
+ * Failed to get the database, unexpected, but let us
+ * at least abandon serve-stale.
+ */
+ return (false);
+ }
+
qctx->client->query.dboptions |= DNS_DBFIND_STALEOK;
if (FETCH_RECTYPE_NORMAL(qctx->client) != NULL) {
dns_resolver_destroyfetch(