]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/ffimodule: call Lua modules unless in FAIL state
authorMarek Vavruša <marek.vavrusa@nic.cz>
Sat, 1 Aug 2015 16:07:03 +0000 (18:07 +0200)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Sat, 1 Aug 2015 16:07:03 +0000 (18:07 +0200)
daemon/bindings/kres.c
daemon/ffimodule.c

index c20e249df680af432cda18e2cd2c3febfb149c0e..16e183a959eb72322ea18961bed983495401cab5 100644 (file)
@@ -183,7 +183,8 @@ static int pkt_question(lua_State *L)
        if (!lua_isnumber(L, 4)) { /* Default class is IN */
                rrclass = KNOT_CLASS_IN;
        }
-       if (!knot_dname_is_equal(knot_pkt_qname(pkt), dname) || pkt->rrset_count > 0) {
+       const knot_dname_t *qname = knot_pkt_qname(pkt);
+       if (pkt->rrset_count > 0 || (!qname || !knot_dname_is_equal(qname, dname))) {
                KR_PKT_RECYCLE(pkt);
                knot_pkt_put_question(pkt, dname, rrclass, rrtype);
                pkt->parsed = pkt->size;
index a0e1d9538d4b919bc44d3785a64326d6a5f3269c..046521a5f051d5907aea244b29e7f7941b4a96bf 100644 (file)
@@ -157,13 +157,12 @@ static int l_ffi_deinit(struct kr_module *module)
 /** @internal Helper for retrieving layer Lua function by name. */
 #define LAYER_FFI_CALL(ctx, slot) \
        int *cb_slot = (int *)((char *)(ctx)->api + sizeof(knot_layer_api_t)); \
+       if (cb_slot[SLOT_ ## slot] <= 0) { \
+               return ctx->state; \
+       } \
        struct kr_module *module = (ctx)->api->data; \
        lua_State *L = module->lib; \
        lua_rawgeti(L, LUA_REGISTRYINDEX, cb_slot[SLOT_ ## slot]); \
-       if (lua_isnil(L, -1)) { \
-               lua_pop(L, 1); \
-               return ctx->state; \
-       } \
        lua_pushnumber(L, ctx->state)
 
 static int l_ffi_layer_begin(knot_layer_t *ctx, void *module_param)
@@ -205,7 +204,7 @@ static int l_ffi_layer_consume(knot_layer_t *ctx, knot_pkt_t *pkt)
 
 static int l_ffi_layer_produce(knot_layer_t *ctx, knot_pkt_t *pkt)
 {
-       if (ctx->state & (KNOT_STATE_FAIL|KNOT_STATE_DONE)) {
+       if (ctx->state & (KNOT_STATE_FAIL)) {
                return ctx->state; /* Already failed or done, skip */
        }
        LAYER_FFI_CALL(ctx, produce);