]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib/resolve: added synchronous cache option
authorMarek Vavrusa <marek@vavrusa.com>
Fri, 27 May 2016 05:00:40 +0000 (22:00 -0700)
committerMarek Vavrusa <marek@vavrusa.com>
Fri, 27 May 2016 05:00:40 +0000 (22:00 -0700)
lib/resolve.c
lib/rplan.h
tests/deckard

index 9d8c7e92cab71b5d95ac27e45fb51147d7269b21..00243a59701c53856a5934199da40f66ecb34dcb 100644 (file)
@@ -57,9 +57,9 @@ static int produce_yield(knot_layer_t *ctx, knot_pkt_t *pkt) { return kr_ok(); }
 
 /** 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, ...) \
@@ -69,7 +69,6 @@ static void flush_caches(struct kr_request *req) {
                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__); \
@@ -77,7 +76,8 @@ static void flush_caches(struct kr_request *req) {
                                } \
                        } \
                } \
-       } /* Invalidate current query. */ \
+       } /* Invalidate current query and maybe flush caches. */ \
+       flush_caches(req); \
        (req)->current_query = NULL
 
 /** @internal Macro for starting module iteration. */
index d0e8e2f3fcb2c553c1641a44ec4ddb91e17e9603..bf8aea328c97d8fd3439f54268670ac833c7b6ee 100644 (file)
@@ -47,6 +47,7 @@
        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 {
index 85cbf82244059113ff3149da04f99089dddc1c5b..1bdecfcde89a39d47dfcc03a0712a04bb668583f 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 85cbf82244059113ff3149da04f99089dddc1c5b
+Subproject commit 1bdecfcde89a39d47dfcc03a0712a04bb668583f