Skip to content
Snippets Groups Projects
Commit 27e8cd62 authored by Marek Vavruša's avatar Marek Vavruša
Browse files

daemon/ffimodule: call Lua modules unless in FAIL state

parent 3714f4bc
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment