From: Marek VavruĊĦa Date: Sat, 1 Aug 2015 16:07:03 +0000 (+0200) Subject: daemon/ffimodule: call Lua modules unless in FAIL state X-Git-Tag: v1.0.0-beta1~62^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27e8cd62cddb68d842061e39571378512935d42d;p=thirdparty%2Fknot-resolver.git daemon/ffimodule: call Lua modules unless in FAIL state --- diff --git a/daemon/bindings/kres.c b/daemon/bindings/kres.c index c20e249df..16e183a95 100644 --- a/daemon/bindings/kres.c +++ b/daemon/bindings/kres.c @@ -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; diff --git a/daemon/ffimodule.c b/daemon/ffimodule.c index a0e1d9538..046521a5f 100644 --- a/daemon/ffimodule.c +++ b/daemon/ffimodule.c @@ -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);