/** Enforce cache flushing in debug mode. */
static void flush_caches(struct kr_request *req) {
-#ifdef DEBUG
- kr_cache_sync(&req->ctx->cache);
-#endif
+ if (req->options & QUERY_CACHE_SYNC) {
+ kr_cache_sync(&req->ctx->cache);
+ }
}
/** @internal Macro for iterating module layers. */
#define RESUME_LAYERS(from, req, qry, func, ...) \
if (mod->layer) { \
struct knot_layer layer = {.state = (req)->state, .api = mod->layer(mod), .data = (req)}; \
if (layer.api && layer.api->func) { \
- flush_caches(req); \
(req)->state = layer.api->func(&layer, ##__VA_ARGS__); \
if ((req)->state == KNOT_STATE_YIELD) { \
func ## _yield(&layer, ##__VA_ARGS__); \
} \
} \
} \
- } /* Invalidate current query. */ \
+ } /* Invalidate current query and maybe flush caches. */ \
+ flush_caches(req); \
(req)->current_query = NULL
/** @internal Macro for starting module iteration. */
X(DNSSEC_WEXPAND, 1 << 19) /**< Query response has wildcard expansion. */ \
X(PERMISSIVE, 1 << 20) /**< Permissive resolver mode. */ \
X(STRICT, 1 << 21) /**< Strict resolver mode. */ \
+ X(CACHE_SYNC, 1 << 22) /**< Sync cache as often as possible. */
/** Query flags */
enum kr_query_flag {